Multiple choice technology programming languages

import java.lang.*; class A { public static void main(String[] args) { String s1=new String("TCS"); String s2="TCS"; System.out.println(s1==s2); System.out.println(s1.equals(s2)); } } What is the Result?

  1. Compile time error

  2. false true

  3. true false

  4. true true

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

The == operator compares object references in Java, returning false because s1 (heap object) and s2 (string literal) are different objects. The equals() method compares string contents, returning true because both contain 'TCS'. This is a fundamental Java concept distinguishing reference equality from value equality.