Encapsulation, Inheritance, and Polymorphism

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Subclass (child class)

A class that inherits properties of another class

Encapsulation

A language mechanism for restricting access to some of the object's components

Inheritance

Allows a class to have the same behavior as another class

Advantage of Polymorphism - Code re-usability

Allows the use of one method name to be used for a variety of different methods, which results in a much simpler approach to programming.

Advantages of Encapsulation

Control the way data is accessed or modified. Security. Makes the class easy to use for clients. Adds to the flexibility of design.

Advantage of Encapsulation - Implementation

Makes it possible to separate an object's implementation from its behavior to restrict access to its internal data. This restriction allows certain details of an objects behavior to be hidden.

Advantage of Inheritance - Maintainability

Since variables and related code are not replicated among different classes if a change is required only one class need be re-written/maintained and therefore less chance of errors in code.

Polymorphism

The ability to redefine methods for derived classes

Superclass (parent class)

The class from which it is inherited

Advantage of Inheritance - Enhanced re-use

The common variables that are declared in the superclass imply that any validation methods or specific coding are already written for these. This means that there is no need to maintain code in two or more places and therefore there is less chance of errors in code.


Set pelajaran terkait

Chapter 1 The Human Body: An Orientation Questions

View Set

Ch 26: Bipolar Disorders: Management of Mood Lability

View Set

Bio 1010 Exam 3 practice questions

View Set

12) Trading strategies with options

View Set

CTC 228 Chapter 7 Review Questions

View Set