Computer Science, asked by shubhi7379, 1 year ago

explain the difference between inheritance and encapsulation with suitable example​

Answers

Answered by Shivansh1mishra
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 priya141723
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