1
visibility
What will be the output of the following Java program?
class string_class
{
public static void main(String args[])
{
String obj = “hello”;
String obj1 = “world”;
String obj2 = “hello”;
System.out.println(obj.equals(obj1) + ” ” + obj.equals(obj2));
}
}
- A
false true
- B
true false
- C
true true
- D
false false
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.