Home » JAVA Programming » Strings » Question
  1. What is the output of this program?

    public class output
    {
    public static void main(String args[])
    {
    String str1 = "Hello i love interview mania";
    String str2 = new String(str1);
    System.out.println((str1 == str2) + " " + str1.equals(str2));
    }
    }
    1. false true
    2. true false
    3. true
    4. false
    5. None of these
Correct Option: A

The == operator compares two object references to see whether they refer to the same instance, where as equals() compares the content of the two objects.



Your comments will be displayed only after manual approval.