SDSU CS535 Object-Oriented Programming & Design
Fall Semester, 1996
Doc 9, Inheritance pt 2, Overriding and Hiding

[To Lecture Notes Index]
San Diego State University -- This page last updated Oct 1, 1996
----------

Contents of Doc 9, Inheritance pt 2, Overriding and Hiding


Doc 9, Inheritance pt 2, Overriding and Hiding Slide # 1Listen Here!
Why not Use the Same rule for both Methods and Fields?
This is polymorphism, examples showing why this is good later
class  Parent  {
   public  int  name  =  5;

   public  void  test() {
      System.out.println( "In Parent \t" + (name / 3) );
   }
}

class  Child  extends  Parent  {
   public String  name  =  "Can't divide me";
}
class FieldsMustBeResolveStaticly {

   public static void main( String args[] ) {

      Child  trouble  =  new Child();
      trouble.test();
   }
}





----------