What is the printout of the following code?
``` List
list.add("A");
list.add("B");
list.add("C");
list.add("D");
for (int i = 0; i < list.size(); i++)
System.out.print(list.remove(i));```
a. ABCD
b. AB
c. AC
d. AD
e. ABC
c Before the loop, the list is [A, B, C, D]. After invoking list.remove(0), the list becomes [B, C, D] and size becomes 3 . Invoking remove(1) now deletes C from the list. The list becomes [B, D]. Now the list size is 2 and i is 2 . So the loop ends.
You might also like to view...
The design view for a select query is divided into three parts
Indicate whether the statement is true or false
In Word, you can insert Office applications, known as ________, that help you individualize your Word documents and gain access to the Internet faster while remaining in Word
A) Word apps B) Office apps C) Internet apps D) Add-ins