Java Constructors and General Programming Quiz

Casual Mode - Take your time!

1 / 20
Correct
0
Incorrect
0
Score
0%
Multiple Choice

What is the result of compiling and running the following code? String s=new String("hello"); StringBuffer sb=new StringBuffer("hello"); System.out.println(s.equals(sb));

  1. Compiler error: String and StringBuffer objects cannot be compared
  2. ClassCastException: String and StringBuffer objects cannot be compared
  3. Prints "true"
  4. Prints "false"
Change Mode