Given the code fragment:
What is the result?
A. [Robb, Rick, Bran]
B. [Robb, Rick]
C. [Robb, Bran, Rick, Bran]
D. An exception is thrown at runtime.
Given the code fragment:
What is the result?
A. [Robb, Rick, Bran]
B. [Robb, Rick]
C. [Robb, Bran, Rick, Bran]
D. An exception is thrown at runtime.
A
public static void main(String[] args) {
List names = new ArrayList();
names.add(“Robb”);
names.add(“Bran”);
names.add(“Rick”);
names.add(“Bran”);
if (names.remove(“Bran”)){
names.remove(“Jon”);
}
System.out.println(names);
}
A