Simple Class Hierarchy - 3 deep
Previous    Next    Home    Source    Package

Notes
  1. Class C subclasses A and B via
       class C extends B {
    
  2. Class C inherits all the local state and methods of class A and some of the local state and all methods of class B.
  3. Although method rand is not defined in class C, an object of class C may invoke it through class A. So, it is class A's rand method that C uses.
  4. Class C's constructor of one argument uses class B's constructor of no arguments and class B's constructor of no arguments uses class A's constructor of no arguments. This means the value of number in class A is unset (it defaults to 0) so when rand in invoked from a C object the result is always 0.
  5. However, the local state of a C object is accessible.