Multiple choice technology programming languages

19 Read this piece of code carefully if("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal");

  1. a. the code will compile an print "Equal".

  2. b. the code will compile an print "Not Equal".

  3. c. the code will cause a compiler error.

  4. d.

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

Calling toString() on the string literal returns the same string object, and string interning in Java often causes identical string literals to reference the same memory location, making the equality operator evaluate to true. Therefore, the code compiles successfully and prints Equal.