Explain the following terms: i. Inheritance ii. Encapsulation iii. Polymorphism

      

Explain the following terms:
Explain the following terms:
i. Inheritance
ii. Encapsulation
iii. Polymorphism

  

Answers


gregory

i. Inheritance
Inheritance is the process by which objects of one class acquire the properties of objects of another class.
A derived class is a class defined by adding instance variables and methods to an existing class.
Inheritance should define a natural is-a relationship between two classes. Private instance variables and
Private methods in a base class are not inherited by a derived class
ii. Encapsulation
The wrapping up of data (instance variables) and functions (methods) into a single unit called class is
known as encapsulation. The data is not accessible to the outside world, and only those functions which
are wrapped in the class can access it. This insulation of the data from direct access by the program is data
hiding or information hiding
iii. Polymorphism
Polymorphism means ability to take more than one form. An operation may exhibit different behaviours
in different instances. The behaviours depend on the types of data used in the operation. Polymorphism
plays an important role in allowing objects having different internal structures to share the same external
interface.
gregorymasila answered the question on January 24, 2018 at 17:36


Next: By use of relevant examples, state the difference between i. Statement and a block. ii. Superclass and subclass iii. Function overloading and overriding
Previous: State four differences between Java applications and Java applets programming.

View More Computer Science Questions and Answers | Return to Questions Index


Exams With Marking Schemes

Related Questions