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 maximum size of arraylist in java?

579


Why is whitespace important?

659


how do I create a runnable with inheritance? : Java thread

621


What is a newline character in java?

664


Why is the main method static?

730






Difference between start() and run() method of thread class?

692


What does split function do in java?

624


What is bitwise complement?

601


What is binary search in java?

661


What is this keyword in java?

669


what is the difference between thread and runnable types? : Java thread

653


What is default switch case? Give example.

657


Can abstract class have private constructor?

585


What does indexof mean?

616


Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?

7562