What is the result of the following?
6: String [] names = {"A", "B", "C"}; 7: List<String> list = names.asList(); 8: list.set(0, "D"); 9: System.out.println(names[0]);
C.
Converting from an array to an ArrayList uses Arrays.asList(names)
.
There is no asList()
method on an array instance.
If this code were corrected to compile, the answer would be option A.