Multiple choice

What is the output of the given program?

StringBuilder sb = new StringBuilder ();

String h1 = HelloWorld;

sb.append(Hello).append (world);

if (h1 == sb.toString())

{

System.out.println(They match);

}

if (h1.equals(sb.toString()))

{

System.out.println(They really match);

}

  1. They Match They Really Match

  2. They really Match

  3. They Match

  4. Blank Output Screen

  5. Compilation fails

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

Strings cannot be compared with the usual <, <=, >, or >= operators, and the == and != operators don't compare the characters in the strings.