Inheritance

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Inheriting instance members and methods

1. A superclass normally contains common features of the entities 2. When we define a subclass as an extension of the superclass the subclass may have its own data member and/or methods TOGETHER with the data members and/or methods from the superclass.

Inheritance concept

1. Inheritance enables an object to inherits data members and methods from the existing object. 2. Allows you to create new classes from existing classes from existing classes New-> subclass/ derived class Existing class -> superclass / base class 3. Inheritance is not limited on ONE level only . A subclass can be superclass to other Subclasses

Inheritance types

1. Single : a subclass derives from a single Superclass 2. Multiple : a subclassderives from more than one superclass

Overloading

If the method in the superclass and the subclass has the same name but different parameter lists .

Overridding

If the subclass give its method the same signature as in the superclass.

Rules of superclasses

Private membersof the superclass are private to the superclass. All its data members are also data members of the subclass. All its methods are also methods for the subclass(unless overridden)

Advantages of inheritance

Save time Code reuse Reduce software complexity

Calling superclass constructor and methods

Super(); Super(len,wei); Super.setDimension(len,wid);

Rules of subclasses

The subclass can directly access the public members of the superclass. The subclass can incluse additional data members and/or methods in its class. The subclass can override the public methods of the superclass.


Kaugnay na mga set ng pag-aaral

root words - claud,clus,caus,close

View Set

Polygon Interior and Exterior Angles

View Set

Python Part 1 of 4 parts - Unit 1

View Set

Anatomy and Physiology 1 Chapter 2 REVIEW QUESTIONS

View Set

MGMT 4373 exam 2 review Dr. Quinn

View Set

SRGT 1542: Final Exam Key Topics (Chapters 16,18-19, 22-24)

View Set

Pharmacology Chapter 18: Key terms, Notes, PrepU

View Set

A&P chapter 5 Integumentary System

View Set

Bone, Cartilages , ligaments, innervation of the larynx

View Set