why the equals method can be override?when we override the
equals method?

Answer Posted / madhu

equals() method will be available in primodian class that is
Object class, but by default it compares only the addresses,
not the contents, So if you want the content comparison you
have to override equals(), but if u override the equals(),
you have to override the hashCode() also.

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What comes to mind when someone mentions a shallow copy in java?

666


These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }

605


What is the largest data type in java?

512


What is meant by nested loop?

546


How can you avoid serialization in child class if the base class is implementing the serializable interface?

641






What is equlas() and hashcode() contract in java? Where does it used?

619


Does constructor be static?

570


In how many ways we can do exception handling in java?

581


How many types of keywords are there?

566


Is set sorted in java?

523


What does jenkins do?

490


Why is the main method static?

608


Why is stringbuffer called mutable?

567


If a method is declared as protected, where may the method be accessed in java programming?

500


What are the two categories of data types in the java programming language?

510