int[] a = {10, 20, 30, 40};
System.out.println(a[2]);What is printed?
- Acheck_circle
30
- B
20
- C
40
- D
2
Explanation
Arrays are 0-indexed, so a[0]=10, a[1]=20, a[2]=30, a[3]=40. Index 2 is the third element, 30.
AP Computer Science A· difficulty 2/5
int[] a = {10, 20, 30, 40};
System.out.println(a[2]);What is printed?
30
20
40
2
Explanation
Arrays are 0-indexed, so a[0]=10, a[1]=20, a[2]=30, a[3]=40. Index 2 is the third element, 30.
Want 10 more like this — adaptive to your weak spots?