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

how many types of Inheritance?

657


List some important features of java 10 release?

517


What is stringreader?

529


Write a program to print 15 random numbers using foreach of java 8?

549


How do you convert int to char in java?

577






How many types of memory areas are allocated by JVM in java?

599


What does .equals do in java?

531


Why can we not override static method?

596


What does || mean in vectors?

478


Can we have multiple catch block for a try block?

592


What is ternary operator in java?

597


What is the syntax and characteristics of a lambda expression? Explain

547


Explain what are final variable in java?

578


What are features of java?

564


explain different ways of using thread? : Java thread

576