ExamVeda
Login
Home
11
How do you find the number of rows in a two-dimensional array named matrix in Java?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
12
What is the default initial value of elements in an array of type boolean in Java?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
13
Which of the following statements is true about arrays in Java?
Discuss
Answer & Solution
Answer: Option D
Solution:
In Java, arrays are objects. They are instances of classes that extend the abstract class java.lang.Object. However, arrays in Java are implemented as objects of a specific type called "Array". This means that arrays in Java are indeed objects, but they are not instances of the Array class; rather, they are instances of classes that are automatically generated by the Java Virtual Machine (JVM) when arrays are created.

Option A: Arrays can change in size after initialization.
In Java, once an array is initialized with a specific size, that size cannot be changed. Arrays have a fixed length determined at the time of creation. While you can create a new array with a different size and copy elements from the old array to the new one to achieve a similar effect, the original array itself cannot change its size.

Option B: Arrays can store elements of different types.
In Java, arrays are homogeneous data structures, meaning they can only store elements of the same type. When you declare an array, you specify the type of elements it can hold. All elements in the array must be compatible with this type.

Option C: Arrays can have a negative length.
In Java, array lengths must be non-negative integers. It is not possible to declare an array with a negative length. Attempting to do so will result in a compilation error.

Therefore, the correct answer is Option D: Arrays are objects of type Array. Arrays in Java are indeed objects, but they are instances of classes that are automatically generated by the Java Virtual Machine (JVM) when arrays are created. They are not instances of the Array class itself, but they are objects nonetheless.
14
What is the correct way to copy the elements of one array to another in Java?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
15
How do you declare and initialize an array of integers with 5 elements in Java?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
16
How do you declare a dynamic array (ArrayList) of integers in Java?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
17
What is the purpose of the System.arraycopy() method in Java?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
Which of the following is true about the size of an ArrayList in Java?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
19
In Java, how do you remove an element at a specific index from an ArrayList named list?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
20
How do you check if an element exists in an array or ArrayList in Java?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board