1. General class inheritance, not necessarily overriding the parent class method.
2. Abstract class inheritance, if the subclass is also an abstract class, does not require that the parent class method must be overridden. If the subclass is not an abstract class, it is required that the subclass implement the abstract method in the parent class.
3. Interface class inheritance. If it is a sub-interface, you can extend the method of the parent interface, if it is a child abstract class, you can implement the parent interface part or all of the method, if the subclass is not an abstract class, it is required that the subclass must implement all the methods defined in the parent interface.
The method in the interface defaults to public abstract
1 PackageCom.hh.Object;2 3 Public classInterface {4 Public Static voidMain (string[] args) {5 6 }7 }8 9 InterfaceAA {//The method in the interface defaults to public abstractTen Public voidMAA (); One } A - InterfaceBB { - Public voidMBB (); the } - - Abstract classCC { - Abstract Public voidMCC (); + } - + InterfaceFfextendsAA, BB {//sub-interface inherits the interface, can extend the method of the parent interface; A at } - - classDdImplementsAA, BB { - - Public voidMBB () { - in } - to Public voidMAA () { + - } the * } $ Panax Notoginseng classEeextendsCcImplementsAA, BB { - Public voidMBB () { the + } A the Public voidMAA () { + - } $ $ @Override - Public voidMCC () { - the } - Wuyi}
View Code
Subclass when inheriting in Java--overriding the parent class method