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 the range of the short type?

584


How do you remove duplicates from an array in java?

531


What is the Difference between Final Class && Abstract Class?

617


Which class represents the socket that both the client and server use to communicate with each other?

574


Explain numeric promotion?

598






What is your platform?s default character encoding and how to know this?

1753


What are format specifiers in java?

596


What are the differences between stringbuffer and stringbuilder?

539


What is callablestatement? How you can call stored procedure to pass in parameter?

545


why we use merge option in hybernate pls give a ex snippet

1464


What is class and object in java?

555


What is a method signature java?

575


Can we assign null to double in java?

549


What are the four corner stones of oop?

547


Is overriding possible in java?

507