Java OCA OCP Practice Question 680

Question

What is the output of the following?

List<String> tools = new ArrayList<>(); 
tools.add("A"); 
tools.add("B"); 
tools.add("C"); 
System.out.println(tools.get(1)); 
  • A. A
  • B. C
  • C. B
  • D. None of the above


C.

Note

An ArrayList does not automatically sort the elements.

It remembers them in order.

Since Java uses zero-based indexes, Option C is correct.




PreviousNext

Related