Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages and disadvantages of java inheritance

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

What are the advantages and disadvantages of java inheritance? most people do not understand the knowledge points of this article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the advantages and disadvantages of java inheritance" article.

1. Advantages

The reuse of the code is improved.

Improve the maintainability of the code.

Making classes related to classes is the premise of polymorphism.

2. Shortcomings

Improve the coupling of classes. A change in such a class will affect other categories related to this class.

Principle: low coupling, high internal polymerization.

Coupling: the relationship between classes.

Cohesion: the ability to accomplish something by yourself.

Broke the encapsulation.

3. Inherit members

The inheritance mechanism introduces protected members and provides a new level of member access control, which can be understood as public and private.

In inheritance, subclasses inherit all members except superstructure functions, which become inherited members of subclasses. Heirs include not only super-defined public, protected and private members, but also super heirs.

In a subclass, a subclass can access all the members it defines, as well as the parent's common and protected inherited members, but not the super private inherited members.

The inheritor's access control in the subclass is the same as its access control in the superclass. At first, it is a common member in the superclass, and the quilt subclass is regarded as a common member after inheritance; it is initially a protected member in the superclass, and the quilt subclass is still a protected member after inheritance; it is initially a private member in the superclass, and the quilt subclass is regarded as a private member after inheritance, but the subclass cannot be accessed. Objects whose data type is a subclass cannot access protected members of the subclass and its parent class.

What are the characteristics of Java? 1.Java language, as the representative of static object-oriented programming language, implements the object-oriented theory and allows programmers to carry out complex programming in an elegant way of thinking.

2.Java has the characteristics of simplicity, object-oriented, distributed, security, platform independence and portability, dynamic and so on.

3. Using Java, you can write desktop applications, Web applications, distributed systems, embedded system applications, and so on.

The above is the content of this article on "what are the advantages and disadvantages of java inheritance?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report