GetClass
The getClass() method returns a Class object that contains information
about a class and utility methods for reflection-based
access to fields and
methods. The getClass() method is final and cannot be overridden
by subclasses.
Finalize
The finalize() method was originally designed to be invoked before
an object was destroyed by the garbage collector. However,
an object might not
become eligible for garbage collection if it’s never dereferenced or if the
application exits before the garbage collector runs. It’s generally discouraged
to rely on this method for cleanup operations due
to its uncertainty and the
possibility that an object can be unintentionally revived by creating additional
references to it.
Wait, Notify, NotifyAll
The final methods wait(), notify(), and notifyAll()
provide low-
level concurrency operations that allow communication between threads.
For example, one thread could halt its execution until it receives a notification
from another thread. Java provides high-level concurrent data structures in the
java.util.concurrent
package.
Questions
What is the difference between a shallow copy and a deep copy?
Why is a copy constructor preferable to the clone method?
What is the difference between the identity operator and the equals() method?
What is the relationship between the hashCode()
method and the
equals() method?
What is the default implementation of the toString() method?
Why is the finalize() method unreliable for cleanup operations?