Question 214 / 297:  What is the result of compiling and running the following code?
import java.util.*;

public class Test {

public static void main(String[] args) {

String[] arr = { "Java", "Champ", "." };

List<String> list = (List<String>) Arrays.asList(arr); // line 1

arr[2] = ".com"; // line 2

for (String word : list) {

System.out.print(word);

}

}

}

A  JavaChamp.
B  JavaChamp.com
C  compilation error at line 1, the correct method is toList not asList
D  compilation error at line 2, cannot modify array after converting to a List
E  compilation error in other lines than lines 1 and 2
<< First < Previous Next > Last >>
Exam Home Page
Ask
Dionne Mahaffey
Start Quiz
Edgar Delgado
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>