Oracle
1Z0-851 · Question #63
Given: 1. public class KungFu { 2. public static void main(String[] args) { 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder("123"); 7. StringBuilder sb2 = sb1…
The correct answer is B. false true. See the full explanation below for the reasoning.
Question
Given: 1. public class KungFu { 2. public static void main(String[] args) { 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder("123"); 7. StringBuilder sb2 = sb1; 8. sb1.append("5"); 9. System.out.println((x == y) + " " + (sb1 == sb2)); 10. } 11.} What is the result?
Options
- Atrue true
- Bfalse true
- Ctrue false
- Dfalse false
- ECompilation fails.
- FAn exception is thrown at runtime.
How the community answered
(20 responses)- A15% (3)
- B70% (14)
- C10% (2)
- E5% (1)
Community Discussion
No community discussion yet for this question.