|
| | Here are some points of interest in this example:
- The keyword extends is used to specify that a class (Manager, in this case) is a subclass of
another class (here, Employee), which is the superclass.
- Class Manager inherits all the data and
methods of class Employee
- Class Manager overrides the
raiseSalary()method
- (Notice the distinction between override and overload.)
- When we call the raiseSalary()method:
- The compiler does not know the
proper method to invoke at compile time
- When the method can be determined at compile time, it is
called compile-time
binding)
- Instead, the compiler generates
code that will dynamically determine the proper method to call at
run time
- When the method is determined at run time, it is called dynamic binding,
late binding, or run-time
binding)
- When we called the print() method, because we did not implement a
print() method on
Manager class, the dynamic binding code finds only the
Employee.print() method, and so calls it.
|