Subclass when inheriting in Java--overriding the parent class method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.