«^»
2.2. Using getClass in the code of equals

Since the equals method appears in a class called Date, you would think that the target of the equals method must be an object of class Date, and so this kind of call of getClass will always return the class Date. However, suppose we derive a class called NamedDate from Date:

public class NamedDate extends Date
{
   private String iName:
   ...
}
Suppose that NamedDate does not override equals. If we write:
tFirstNamedDate.equals(tSecondNamedDate)
then this will be a call of Date's equals method and both calls of getClass will return the class NamedDate. So, even though this code appears in the class declaration for Date, in some circumstances the first call of getClass will return a value that is a subclass of the class Date.