PRONS AND CONS OF USING ARRAYS: Set 01: Pro: It can hold the collection of simil
ID: 3602360 • Letter: P
Question
PRONS AND CONS OF USING ARRAYS: Set 01: Pro: It can hold the collection of similar items Con: It can hold the collection of similar items only Set 02: Pro: Memory allocated is continuous. You can increment the index to move to next element. You can refer to any item in array using its index Con: Memory allocated is continuous. If that required amount of memory is not continuously avail, well, problem! Insertion and deletion in between the array are tedious to handle. Set 03: Pro: You can do operations on this homogeneous collection of items like sort, search, etc. Con: If the size of data grows huge (Huge data as well as huge integer range), arrays are not the ideal data structures to be used. Set 04: Pro: Many other data structures can be implemented using arrays (Stack, Queue, Matrices etc) Con: The static size and no direct bound checking mechanism is always a disadvantage.
Set 01 to Set 04 refers to what in java?
Explanation / Answer
Set 01: in java
Prons:
In java Array creation is dynamic..where as in c it is not dynamic..Arrays first created and initialized.Since we can store many of elements at a time.
Cons:
yes,in java array can hold ony similar type of data types .different types are not posible.if we create array of type integers it allows only integers .not strings chars etc.
Set2:
Prons:
In java we can access element by index value. we can add many elements at a time.which is fast.we can access any particular element by using index of array randomly .
Cons:In java if the elements reaches the limit of array..it throws an exception called ArrayIndexOutOfBoundsException..this exception is thrown when supose array size is 5 and we inserted or try to access element more than size it throws exception
Set3:
Prons:
In java arrays are widely used for sorting and searching of elements.and it is faster
Cons:
arrays are very expensive in deletion
arrays are very expensive in adding compare linked list
arrays are fixed in size ..size cannot be increased once created.but where as linked list are not limited they can increase size dynamically..
and also size of arrays are not even decreased
Set 4:
arrays can be used for implemented many data structures like stack queue etc,and accessing elements from these data structures are quite good
and java also provides predefined data structures like stack queue..
cons:
when even any element is accessed java checks the index values are within limit or not which is causes the reduction in speed limit.arry bound checks elimination identifies a situation that such ones are redundant
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.