21. |
What will be the output of the following Java code?
class multidimention_array { public static void main(String args[]) { int arr[][] = new int[3][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] = new int[3]; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) arr[i][j] = j + 1; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) sum + = arr[i][j]; System.out.print(sum); } }
|
||||||||
Answer:
Option (b) |
22. |
What will be the output of the following Java code?
class evaluate { 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.println(arr[n] / 2); } }
|
||||||||
Answer:
Option (d) |
23. |
What will be the output of the following Java code?
class array_output { 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] + ""); } } }
|
||||||||
Answer:
Option (d) |
24. |
What will be the output of the following Java 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); } }
|
||||||||
Answer:
Option (b) |
25. |
What is the type of variable ‘b’ and ‘d’ in the following Java snippet?
int a[], b; int []c, d;
|
||||||||
Answer:
Option (c) |
26. |
What will be the output of the following Java code snippet?
Object[] names = new String[3]; names[0] = new Integer(0);
|
||||||||
Answer:
Option (b) |
27. |
Generics does not work with?
|
||||||||
Answer:
Option (d) |
28. |
How to sort an array?
|
||||||||
Answer:
Option (b) |
29. |
How to copy contents of array?
|
||||||||
Answer:
Option (a) |
30. |
Where is an array stored in memory?
|
||||||||
Answer:
Option (a) |