Oracle
1Z0-819 · Question #185
1Z0-819 Question #185: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #185. The question stem and answer options stay visible for context.
Question
Given:
public class Main {
public static void main(String[] args) {
List<String> list1 = new ArrayList<>();
list1.add("Plane");
list1.add("Automobile");
list1.add("Motorcycle");
List<String> list2 = new ArrayList<>(List.copyOf(list1));
list1.sort((String item1, String item2) -> item1.compareTo(item2));
list2.sort((String item1, String item2) -> item1.compareTo(item2));
System.out.println(list1.equals(list2));
}
}
What is the result?
Options
- AA
java.lang.UnsupportedOperationExceptionis thrown. - BTrue
- CFalse
- DA
java.lang.NullPointerExceptionis thrown. - EThe compilation fails.
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.