Computer Applications

Explain the difference between Inheritance and Encapsulation with suitable examples.

OOP Intro Java

51 Likes

Answer

Encapsulation is a mechanism that binds together code and the data it manipulates whereas Inheritance is the mechanism by which a class acquires the properties and methods of another class. An ATM binding together the different denominations of currency notes and all the operations required to withdraw cash is an example of Encapsulation. Classifying Vehicles as Car, Bike, Bus, Truck, etc. is an example of Inheritance.

Answered By

29 Likes


Related Questions