Multiple choice technology programming languages

What is the result of compiling and running the following code ? 1. StringBuffer s1=new StringBuffer("hello"); 2. StringBuffer s2=new StringBuffer("hello"); 3. Float f1=9.0F; 4. Double f2=9.0; 5. System.out.print(f1.equals(f2)); 6. System.out.print(s1==s2); 7. System.out.print(s1.equals(s2));

  1. Prints "truetruetrue"

  2. Prints "falsefalsetrue"

  3. Prints "falsefalsefalse"

  4. Compiler error on line 5

  5. Compiler error on line 7

  6. None

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Float.equals(Double) returns false because they're different types (Float vs Double). s1==s2 returns false because they're different StringBuffer objects. s1.equals(s2) returns true because StringBuffer.equals() compares content. Result: 'falsefalsetrue'.