Q. What will be the output of the following code
Code:import java.util.List;
public class ArrayListTest {
public static void main(String args[])
{
List<String> arrayList=new ArrayList<String>();
arrayList.add(“a”);
arrayList.add(“a”);
arrayList.clear();
arrayList.add(“b”);
arrayList.add(“b”);
System.out.println(arrayList.size());
}
}
β
Correct Answer: (B)
2