JAVA inherits extends and java inherits extends

Source: Internet
Author: User

JAVA inherits extends and java inherits extends

 

/* Inheritance 1. improves code reusability, simplifies code 2, and creates an inheritance relationship between classes. Note the following polymorphism features: do not create an inheritance relationship to simplify the code in order to obtain the functions of other classes. The inheritance relationship must exist between the class and the class: is) 3. sub-classes have members of the parent class 4. sub-classes cannot have members of the parent class after being Private. 5. JAVA supports multi-layer inheritance. The lowest-level sub-classes in multi-layer inheritance have the entire inheritance system. member, description of the commonalities of all sub-classes defined in the parent class at the top layer JAVA does not support multi-inheritance, but only supports single inheritance, because multi-inheritance has security risks (this multi-inheritance is not multi-layer inheritance, but a class does not support inheriting multiple classes at the same time. When multiple parent Classes define the same members, the subclass object is not sure which one to run. JAVA retains this mechanism and uses another method to demonstrate (multiple implementations) * // parent class, superclass, base class Porson {String name; int age ;} // subclass class Student extends Porson {void stuby () {System. out. println ("Learning") ;}// subclass class Teather extends Porson {void teath () {System. out. println ("") ;}} public class Test {public static void main (String [] args) {}}/* English extension: porson: student teather: instructor */

 

Related Article

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.