Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| |||||||||||
Core Java - Interview Questions and Answers for 'Equals method' - 2 question(s) found - Order By Newest | |||||||||||
| |||||||||||
Ans. it depends on the implementation of equals method of the respective class. If no definition is provided and it uses the default definition of the object class, two references are equal only if they point to the same object. We can have such an equality defined for a particular class objects if we provide appropriate implementation of equals method comparing all those fields. | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
| |||||||||||
Ans. str.equals("") this statement will throw NullPointerException if str is null where as "".equals(str) works fine even if str is null | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() ![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
| |||||||||||