Search

Basics of Encapsulation Inheritance & Polymorphism

Encapsulation:

Hiding the data/methods inside the object is called the Encapsulation.

In Structured programming when u want to have a variable having accessible by some part and not by other part u don't have a mechanism to achieve the same.

Encapsulation provides the same mechanism, if a class or a function wants to access then it should access those variables and functions from the references of the class i.e. objects.

Inheritance

Inheritance enables you to create a class that is similar to a previously defined class, but one that still has some of its own properties.

Polymorphism

The last major feature of object-oriented programming is polymorphism. By using polymorphism, you can create new objects that perform the same functions as the base object but which perform one or more of these functions in a different way. For example, you may have a shape object that draws a circle on the screen. By using polymorphism, you can create a shape object that draws a rectangle instead. You do this by creating a new version of the method that draws the shape on the screen.

It also includes run-time polymorphism.

No comments:

Post a Comment