using equals method overriding which objects are
compared?i.e same class objects or other class
objects?Explain me.

Answer Posted / r.jainrocks@gmail.com

we compare with same class object...

let me know when u override equals() method
u code like--->

this.name.equals(obj.name);

so this comparison is with same class object not with
other class.....

if there is other class class object then
ClassCastException may occur due wrong casting...

so be careful while using equals method overriding....

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is assembly condition codes?

746


Can we write class inside a class in java?

733


What does the “static” keyword mean?

806


How to avoid memory leak in java?

827


Can a method be overloaded based on different return type but same argument type?

728


Do I need java for windows 10?

754


What does indexof mean?

707


Discuss different types of errors that generally occur while programming.

780


What happens if we override only equals?

749


What is the use of default method in interface in java? Explain

742


String class is defined under which package in java?

806


What is not thread safe?

736


Are functions objects in java?

784


What is integer parseint?

723


Which package is always imported by default?

772