int[] a;
a = new int[]{2, 4, 6};
System.out.println(a[1]);What is printed?
- Acheck_circle
4
- B
2
- C
6
- D
Compilation error
Explanation
After declaration, a is assigned a new int array {2,4,6}. The shorthand {2,4,6} is only valid in declarations; here we use new int[]{...}. a[1] is 4.