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 'Object class' - 5 question(s) found - Order By Newest | |||||||||||
![]() | |||||||||||
| |||||||||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory. x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object. Sample code: String x = new String("str"); String y = new String("str"); System.out.println(x == y); // prints false System.out.println(x.equals(y)); // prints true | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
| |||||||||||
Ans. clone() - Creates and returns a copy of this object. equals() - Indicates whether some other object is "equal to" this one. finalize() - Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. getClass() - Returns the runtime class of an object. hashCode() - Returns a hash code value for the object. toString() - Returns a string representation of the object. notify(), notifyAll(), and wait() - Play a part in synchronizing the activities of independently running threads in a program. | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||
![]() | |||||||||||
| |||||||||||
Ans. java.lang.StringBuffer. | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() ![]() ![]() | |||||||||||
| |||||||||||
Ans. 1. Default definition for some of the methods , like equals, hashcode etc that gets carried to all objects even if you don't define anything. But that default definition is kind of like assigning 0 to integer, it just provide a safe state , nothing much for comparison. 2. Places where you have no idea about what object you may receive and just want to perform out of 8 basic methods of object class, something like printing their string representation ( defined by their toString method ), or equality ( using their equals method ) | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() | |||||||||||
| |||||||||||
Ans. wait and notify are declared final in object class and hence cannot be overridden. | |||||||||||
![]() | |||||||||||
![]() ![]() ![]() | |||||||||||
| |||||||||||