227k views
1 vote
What is the size of the ArrayList aList after the following code segment is executed?

ArrayList‹Double› aList = new ArrayList‹Double›(3);
aList.add(3.5);
aList.add(4.3);
aList.add(1, 12.3);
aList.set(2, 18.9);
aList.add(−42.6);
aList.set(0, −20.3);
aList.remove(3);
aList.add(24.8);

A 3
B 4
C 7
D 9
E An IndexOutOfBoundsException error occurs

1 Answer

3 votes

Answer:

Size = 4

Step-by-step explanation:

*Look at the picture*

What is the size of the ArrayList aList after the following code segment is executed-example-1
User Splashdust
by
3.5k points