1. In Java, arrays are objects of which class? A. Array B. Collection C. ArrayList D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
2. How do you declare a one-dimensional array in Java? A. int[] myArray; B. int myArray[]; C. Array myArray; D. All of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
3. What is the default initial value of numeric elements in an array of type int in Java? A. 0 B. 1 C. -1 D. Null Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
4. What is the correct way to initialize a two-dimensional array in Java? A. int[][] myArray = {{1, 2}, {3, 4}}; B. int[2][2] myArray = {{1, 2}, {3, 4}}; C. int[2][2] myArray; myArray[0][0] = 1; myArray[0][1] = 2; myArray[1][0] = 3; myArray[1][1] = 4; D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
5. What does the length attribute of an array in Java represent? A. The number of elements in the array B. The maximum value of elements in the array C. The length of the variable name D. The number of dimensions Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
6. How do you access an element in a one-dimensional array named myArray at index 3 in Java? A. myArray[3] B. myArray(3) C. myArray.get(3) D. myArray.getElement(3) Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
7. What happens if you try to access an array element at an index that is out of bounds in Java? A. It returns null. B. It throws an ArrayIndexOutOfBoundsException. C. It returns 0. D. It returns -1. Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
8. Which method is used to find the length of an array in Java? A. length() B. size() C. getSize() D. length Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
9. What is the highest index of an array with 10 elements in Java? A. 9 B. 10 C. 0 D. 1 Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
10. Which of the following is a valid declaration and initialization of a String array in Java? A. String[] names = {"Alice", "Bob", "Charlie"}; B. String names[] = {"Alice", "Bob", "Charlie"}; C. String[3] names = {"Alice", "Bob", "Charlie"}; D. All of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board