Question: 6 -
Which of the following is advantage of java array?
-
Both Code Optimization and Random access
-
Code Optimization
-
Random access
-
Size No-Limit
Answer:
Both Code Optimization and Random access
Solution not available.
Question: 7 -
We can calculate the length of an array using ________.
-
array.sizeof()
-
sizeof(array)
-
array.len
-
array.length
Answer:
array.length
Solution:
We can calculate the length of an array using array.length.
We can calculate the length of an array using array.length.
Question: 8 -
Which of the following is used to declare,construct, and initlaize an array?
-
int [] arr = (1, 2, 3);
-
int [] arr = {};
-
int arr [] = {1, 2, 3};
-
int arr [] [] = {1, 2, 3, 4};
Answer:
int arr [] = {1, 2, 3};
Solution:
int arr [] = {1, 2, 3}; is used to declare,construct, and initlaize an array becuase Option A is wrong because it initializes an int array with String literals. Option B is wrong because it uses something other than curly braces for the initialization. Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.
int arr [] = {1, 2, 3}; is used to declare,construct, and initlaize an array becuase Option A is wrong because it initializes an int array with String literals. Option B is wrong because it uses something other than curly braces for the initialization. Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.
Question: 9 -
In java, array elements are stored in ________ memory locations.
-
Sequential
-
Random
-
Sequential & Random
-
Binary search
Answer:
Sequential
Solution:
Array elements are stored in contiguous memory. Linked List is stored in random memory locations.
Array elements are stored in contiguous memory. Linked List is stored in random memory locations.