Monday, 2 January 2012

Question 59 : String Handling

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 ?

A. true true
B. false true
C. true false
D. false false
E. Compilation fails.
F. An exception is thrown at runtime.

No comments:

Post a Comment