Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the following method will cause runtime errors?

Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the following method will cause runtime errors?


A. x.get(1)
B. x.set(2, "New York");
C. x.get(2)
D. x.remove(2)
E. x.size()

The correct answer is BCD

Explanation: There is no element at index 2.


Java

Learn More Multiple Choice Question :