Question: Given: public class Demo 1 1 public static void main ( String args ) String 5 1 = new String ( Hi )
Given:
public class Demo
public static void mainString args
String new StringHi;
string s new StringHi;
System.out.println;
System.out.printlnsequalss;
Object ;
Object
System.out.println;
System.out.printlnequals:
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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
