Question: Given: public class Demo 1 1 public static void main ( String args ) String 5 1 = new String ( Hi )

Given:
public class Demo11
public static void main(String args)
String 51= new String("Hi");
string s2= new String("Hi");
System.out.println(51==s2;
System.out.println(s1.equals(s2));
Object 01=51;
Object 02=52
System.out.println(01==02);
System.out.println(01.equals(02)):
Which of the following statements are incorrect when considering the above code?
equals() and == produce the same output for String objects as the equals() method is overridden in the String class.
equals() and == produce different output for String objects as the equals() method is not overridden in the String class.
== compares reference of objects while equals() compares the values in the objects
The output produced by equals() and == will be the same for objects of Object and String type, regardless of whether the equals() method is overridden by the string class.
Given: public class Demo 1 1 public static void

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!