Supplement to The Interface --- The Inheritance of Polymorphism

The Inheritance of Polymorphism

The characteristics of the inheritance of polymorphism is the subclass type turn to the superclass type

class Father{

}

class Child extends Father{

}

public class MyClass{
main(){
  Child a = new Child();
  Father b = new Father();
  test(a);
  }
public static void test(Father b){

  }
}
class abstract Father{

}

class Child extends Father{

}

public class MyClass{
main(){
  Child a = new Child();
  Father b = new Father();
  test(a);
  }
public static void test(Father b){

  }
}

你可能感兴趣的:(Supplement to The Interface --- The Inheritance of Polymorphism)