Java Programming Multiple Choice Questions - Array
This section focuses on the "Array" of the Java programming. These Multiple Choice Questions (mcq) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1.Which of these operators is used to allocate memory to array variable in Java?
Explanation: Operator new allocates a block of memory specified by the size of an array, and gives the reference of memory allocated to the array variable.
2. Which of the following is FALSE about arrays on Java
Explanation: In Java, arrays are objects, they have members like length. The length member is final and cannot be changed. All objects are allocated on heap in Java, so arrays are also allocated on heap.
3. Which of these is necessary to specify at time of array initialization?
Explanation:Row is necessary to specify at time of array initialization .
4. In java array object are
Explanation:In java an array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.
5. Which of these is an incorrect array declaration?
Explanation: Operator new must be succeeded by array type and array size.
6. When you pass an array to a method, the method recieve
Explanation: When you pass an array to a method, the method recieve "The reference of the array".
7. Which will legally declare,construct, and initlaize an array?
Explanation: The only legal array declaration and assignment statement is Option D
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.
8. Generics does not work with?
Explanation:Generics gives the flexibility to strongly typecast collections. Generics is applicable to Set, List and Tree. It is not applicable to Array.
9. Where is array stored in memory?
Explanation: Array is stored in heap space. Whenever an object is created, it’s always stored in the Heap space and stack memory contains the reference to it.
10.An array elements are always stored in ________ memory locations?
Explanation:Array elements are stored in contiguous memory. Linked List is stored in random memory locations..
Also check :