What is equals method in Java ?

Search Interview Questions

 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text


Interview Questions and Answers

 Q1. What is equals method in Java ?Core Java
Ans. equals is the method of Object class that is overridden by the classes to specify object equality criteria.

As every class extends Object class, the default implementation of equals is carried to them. Default implementation specified in the Object class is that two objects are treated equal if they are same.


Object x = new Object();
Object y = new Object();
x.equals(y); // false
x.equals(y); // true

i.e x.equals(y) if only x==y

Now every class has the option to specify their object equality by overriding equals method. For example - String class has implemented in a manner if the string value contained in them is exactly same.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     equals

Related Questions

  Difference between == and .equals() ?
  Which String class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
  Can we compare Integers by using equals() in Java ?
 In Java, if object A contains same the same data of object B, are they equal?
 Write a class and override the equals and hashcode method ?
 What is a reflexive equals contract ?
 Explain Transitive equals contract.
 why is "".equals(str); safer than str.equals("")?
 Difference between equals and compareTo in Java ?

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: