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

    public class stringClass_Example
    {
    public static void main(String args[])
    {
    String str = "Interview";
    String str1 = "Mania";
    String str2 = "Interview";
    System.out.println(str.equals(str1) + " " + str.equals(str2));
    }
    }
    1. true true
    2. false false
    3. false true
    4. true false
    5. None of these
Correct Option: C

equals() is method of class String, it is used to check equality of two String objects, if they are equal, true is retuned else false.
output: false true



Your comments will be displayed only after manual approval.