Multiple choice technology programming languages

if("String".toString() == "String") System.out.println("Equal");else System.out.println("Not Equal");

  1. Code will give compile time error

  2. Code will give runtime error

  3. Code will print "Equal"

  4. Code will print "Not Equal" ==

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

The toString() method on a string literal returns the same string instance, and string literals are interned in Java, making both reference equality and content comparison true, which prints Equal.