比较类似术语之间的差异

Difference Between

家 / Technology / IT / Programming /Difference Between Superclass and Subclass

Difference Between Superclass and Subclass

January 22, 2018Posted byLithmee

Key Difference – Superclassvs Subclass

InObject Oriented Programming(OOP),该系统是使用objects.这se objects are created using a班级.一个类是一个蓝图or a description to create an object. Object creation is also known as object instantiation. Each object is communicating with other objects. A program or software can be developed using Object Oriented Programming.Inheritance是OOP中的主要概念。它改善了代码可重复性。它不是从一开始就实现程序,而是允许将已经存在的类的属性和方法继承到新类。它有助于使程序更易于管理。超类和子类是与继承有关的两个术语。本文讨论了超类和子类之间的差异。这key differencebetween the Superclass and Subclass is thatSuperclass is the existing class from which the new classes are derived while Subclass is the new class that inherits the properties and methods of the Superclass.

内容

1.Overview and Key Difference
2.什么是超级类
3.What is Subclass
4.Similarities Between Superclass and Subclass
5.Side by Side Comparison – Superclass vs Subclass in Tabular Form
6。概括

什么是超级类?

在继承中,新类得出的现有类称为超类。它也称为父级或基类。

有不同的继承类型。使用以下示例进行了说明。将B和C视为课程。

Difference Between Superclass and Subclass

图01:继承类型

Difference Between Superclass and Subclass_Figure 02

Figure 02: Hybrid Inheritance

根据上图,超类别与每种继承类型不同。在单层继承中,A是超类。在多级继承中,a是B和B的超类是C的超类。在层次结构的继承a是B和C的超类。在多个继承中,A和B都是C的超级类别。

Hybrid inheritance is a combination ofmulti-level and multiple inheritances.In the left-hand side diagram, A is the Superclass for B, C and B, C are the Superclasses for D. In the right-hand side diagram, A is the Superclass for B and B, D are Superclasses for C.

Refer the below program written in Java.

超类和子类之间的关键区别

Figure 03: Inheritance Program in Java

According to the above program, class A have sum() and sub() methods. Class B has multiply() method. Class B is extending class A. Therefore, properties and methods of class A are accessible by class B. Therefore, class A is the Superclass. The reference type of class B is taken to create the object. So, all methods such as sum(), sub() and multiply() are accessible by the object. If Superclass reference type is used for object creation, the members of class B cannot be accessible. e.g. A obj = new B(); Therefore, Superclass reference cannot call the method multiply() because that method belongs to class B.

What is Subclass?

According to the above diagrams, Subclasses varies from each inheritance type. In Single Inheritance, B is the Subclass. In multi-level inheritance, B is the Subclass of A and C is the Subclass of B. In Hierarchical Inheritance B and C are Subclasses of A. In multiple inheritances, C is the Subclass for A and B.

In Hybrid inheritance, the diagram in the left, B and C are Subclasses of A. D is the Subclass of B and C. In the diagram to the right, B is the Subclass for A. C is the Subclass of B and D.

According to the above Inheritance program, class B is extending class A. Therefore, all properties and methods of class A are accessible by class B. Class B is the new class that inherits from class A. It is known as the Subclass. It is also known as the child class or derived class. Class B has multiply () method and it can also access sum() and sub() methods of class A using inheritance.

What is the Similarity Between Superclass and Subclass?

  • Both are related to Inheritance.

超类和子类有什么区别?

超类与子类

实施继承时,新类的现有类是超类。 When implementing inheritance, the class that inherits the properties and methods from the Superclass is the Subclass.
Synonyms
Superclass is known as base class, parent class. 子类被称为派生类,儿童班。
功能
A superclass cannot use the properties and methods of the Subclass. A subclass can use the properties and methods of the Superclass.
Single-Level-Inheritance
有一个超类。 有一个子类。
Hierarchical Inheritance
这re is one Superclass 这re are many Subclasses.
多元继承
这re are many Superclasses. 有一个子类。

概括– Superclassvs Subclass

继承是OOP的概念。它允许使用新类访问现有类的属性和方法。继承的类是超级类,派生类是子类。超类和子类之间的区别在于,超类是从中得出新类的现有类,而子类是继承超级类的属性和方法的新类。

Download the PDF Superclass vs Subclass

You can download PDF version of this article and use it for offline purposes as per citation note. Please download PDF version hereDifference Between Superclass and Subclass

Reference:

1.“Inheritance in Java – Javatpoint.”这Point,Available here
2.tutorialspoint.com. “Java Inheritance.”这Point,Available here

相关文章:

Java和JavaScript之间的区别 Ajax和JQuery之间的区别Difference Between Ajax and jQuery Difference Between Struts and Struts2 Difference Between Static and Non Static Method Difference Between Inheritance and Composition

Filed Under:Programming标记为:比较超类和子类,Subclass,子类定义,Subclass Functionality,Subclass Inheritance,子类同义词,Superclass,Superclass and Subclass Differences,Superclass and Subclass Similarities,Superclass Definition,Superclass Functionality,超类的继承,Superclass Synonyms,超类与子类

关于the Author:Lithmee

Lithmee Mandula是计算机系统工程的孟加(荣誉)。她目前正在攻读计算机科学硕士学位。她在写作和研究方面的兴趣领域包括编程,数据科学和计算机系统。

发表评论取消回复

Your email address will not be published.Required fields are marked*

请求文章

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

冠状病毒和SARS之间的差异

冠状病毒和SARS之间的差异

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Covid 19

Difference Between Coronavirus and Covid 19

你可能喜欢

Difference Between Interim and Acting

Difference Between Narrowband and Wideband

Difference Between Acrania and Craniata

Difference Between Acrania and Craniata

Difference Between Chrysalis and Cocoon

Difference Between Chrysalis and Cocoon

Difference Between Actual and Formal Parameters

Difference Between Actual and Formal Parameters

最新的帖子

  • What is the Difference Between Solution Suspension and Emulsion
  • What is the Difference Between Constipation and Diarrhea
  • 土壤质地和土壤结构有什么区别
  • 阑尾炎和克罗恩病有什么区别
  • 真空泵和压缩机有什么区别
  • What is the Difference Between Soil and Clay
  • 家
  • Vacancies
  • 关于
  • 请求文章
  • 联系我们

Copyright © 2010-2018Difference Between.All rights reserved.Terms of Use和隐私政策:合法的.