← Quiz: Java Arrays: all 10 questions
Quiz: Java Arrays · Question 3 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
int[] a = {1, 2, 3};
int[] b = a;
b[0] = 9;
System.out.println(a[0]);
}
}
- A.1
- B.9
- C.0
- D.Error
Answer & explanation
Correct answer: 9
a and b refer to the same array object.
Can you get the rest right without peeking?
Take the timed Quiz: Java Arrays quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →