Oracle
1Z0-851 · Question #167
1Z0-851 Question #167: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #167. The question stem and answer options stay visible for context.
Question
Given: import java.util.*; public class WrappedString { private String s; public WrappedString(String s) { this.s = s; } public static void main(String[] args) { HashSet<Object> hs = new HashSet<Object>(); WrappedString ws1 = new WrappedString("aardvark"); WrappedString ws2 = new WrappedString("aardvark"); String s1 = new String("aardvark"); String s2 = new String("aardvark"); hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2); System.out.println(hs.size()); } } What is the result?
Options
- A0
- B1
- C2
- D3
- E4
- FCompilation fails.
- GAn exception is thrown at runtime.
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 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.