 
 
 
 
 
   
 Next: Overriding of methods: example
 Up: Unit 08
 Previous: Access to the public
- We say that we do overriding of a method m() when we
  define in the subclass a method m() having exactly the same
   signature as the method m() in the superclass.
- When we do overriding, Java requires that the definition of the new
  method m() has also the same return type as the original method
  m().  In other words, the method we are redefining must have the
  same header as the original method.
- The consequence of overriding is that, each time we invoke the method
  m() on an object of the derived class D, the method that is
  effectively called is the one redefined in D, and not the one
  defined in the base class B, even if the reference used to denote
  the invocation object is of type B.  This behavior is called
  polymorphism.
- Note that overriding is different from overloading (which
  is the definition of two methods with the same name but different signatures).
 
 
 
 
 
   
 Next: Overriding of methods: example
 Up: Unit 08
 Previous: Access to the public