the toString() and equals() methods are the methods of Object class, since all classes inherit these methods, but on using such methods we get some different results this is because when we use toString() method of Object class then it convert the details of object (class name and address) into the string similarly when we use equals() method of Object class then the reference of the objects will be compared not their values, therefore in order to get the object details we need to override the toString() method of object class in the child class, and similarly in order to use the logical equality (instead of reference equality) we need to override the equals() method in the child class.
Get Answers For Free
Most questions answered within 1 hours.