Oracle
1Z0-809 · Question #155
Given the code fragment: public class Test { public static void main(String[] args) { StringBuilder sb = new StringBuilder(5); String s = ""; if (sb.equals(s)) { System.out.println("Match 1"); }…
The correct answer is A. Match 2. You've hit your session limit · resets 10:20pm (America/New_York)
Question
Given the code fragment:
public class Test {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder(5);
String s = "";
if (sb.equals(s)) {
System.out.println("Match 1");
} else if (sb.toString().equals(s.toString())) {
System.out.println("Match 2");
} else {
System.out.println("No Match");
}
}
}
What is the result?
Options
- AMatch 2
- BMatch 1
- CNo Match
- DA NullPointerException is thrown at runtime.
How the community answered
(47 responses)- A81% (38)
- B11% (5)
- C2% (1)
- D6% (3)
Explanation
You've hit your session limit · resets 10:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.