Array in Java MCQs

@T-Bone

This question paper 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.

This question paper 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.

Questions

1. Java array is a collection of ________.

Mark the correct option

2. Array data access using _____.

Mark the correct option

3. At time of array initialization which is necessary to specify?

Mark the correct option

4. Java Array can allocate __________.

Mark the correct option

5. Which of the following is an incorrect array declaration?

Mark the correct option

6. Index in array start with ______.

Mark the correct option

7. Which of the following is used to declare,construct, and initlaize an array?

Mark the correct option

8. We can calculate the length of an array using ________.

Mark the correct option

9. Which of the following is advantage of java array?

Mark the correct option

10. In java, array elements are stored in ________ memory locations.

Mark the correct option

11. What will be the output of the program? class Main { public static void main(String args[]) { int arr[] = {10, 20, 30, 40, 50}; for(int i=0; i < arr.length; i++) { System.out.print(" " + arr[i]); } } }

Mark the correct option

12. What will be the output of the program? int arr[] = new int [5]; System.out.print(arr);

Mark the correct option

13. What will be the output of the program? class Main { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i; System.out.print(array_variable[i] + " "); i++; } } }

Mark the correct option

14. What will be output for the following code? class Main { public static void main(String args[]) { int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9}; int n = 6; n = arr[arr[n] / 2]; System.out.print(n); } }

Mark the correct option

15. Predict the output of following Java Program? class Main { public static void main(String args[]) { char array_variable [] = new char[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = 'i'; System.out.print(array_variable[i] + " "); } } }

Mark the correct option

16. What will be output for the following code? class Test { public static void main(String args[]) { int arr[2]; System.out.println(arr[0]); System.out.println(arr[1]); } }

Mark the correct option

17. What will be output for the following code? class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); System.out.println(arr[1]); } }

Mark the correct option

18. What will be output for the following code? class array_output { public static void main(String args[]) { int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}}; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < 3 ; ++j) sum = sum + array_variable[i][j]; System.out.print(sum / 5); } }

Mark the correct option

19. What will be the output of the program? class Main { public static void main (String[] args) { int arr1[] = {1, 2, 3}; int arr2[] = {1, 2, 3}; if (arr1 == arr2) System.out.println("Same"); else System.out.println("Not same"); } }

Mark the correct option

20. What is the output of this program? class Main { public static void main (String[] args) { int arr1[] = {1, 2, 3}; int arr2[] = {1, 2, 3}; if (arr1.equals(arr2)) System.out.println("Same"); else System.out.println("Not same"); } }

Mark the correct option

21. Which of these is an incorrect Statement?

Mark the correct option

22. What is the type of variable "b" and "d" in the below snippet? int a[], b; int []c, d;

Mark the correct option

23. Which of these is necessary to What is the output of below snippet?specify at time of array initialization? Object[] names = new String[3]; names[0] = new Integer(0);

Mark the correct option

24. How to sort an array?

Mark the correct option

25. How to copy contents of array?

Mark the correct option

Index of Questions