explain the difference between inheritance and encapsulation with suitable example
Answers
Answered by
6
Encapsulation is a mechanism of wrapping the properties together as a single unit. In OOP, think of a class as an encapsulated unit of states(variables) and behaviours(methods/functions). Encapsulation allows Data-Hiding and Data Abstraction. ... In OOP, polymorphism is achieved through inheritance.
Answered by
1
INHERITANCE
Inheritance is one in which is new class is created that inherits the features from the already existing class
ENCAPSULATION
Encapsulation is the way in which data and methods/function are combined together in the form of single unit
Similar questions