Object-Oriented Programming (OOPs)

Published: (February 5, 2026 at 09:07 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Class

Example: Car is a class. Different cars may have different names and brands, but all share common properties like four wheels, speed limit, and mileage.

Object

An object is the basic element of Object‑Oriented Programming that represents real‑life entities. It is created from a class, and memory is assigned when the object is instantiated. Every object has identity, state, and behavior.

For example, “Dog” is a real‑life object, which has characteristics such as color, breed, bark, sleep, and eats.

Data Abstraction

Example: A person driving a car knows that the accelerator increases speed and the brakes stop the car, but does not know how the internal system works. This is called abstraction.

Encapsulation

Encapsulation is the process of combining data and methods into a single unit. It binds together the code and the data it operates on. In encapsulation, class variables are hidden from other classes and can be accessed only through the class’s member functions. Because the data is protected from outside access, encapsulation is also called data hiding.

Inheritance

Inheritance is an important concept in Object‑Oriented Programming. It allows one class to use the properties and methods of another class. This means a new class can reuse existing code instead of writing everything again. As a result, inheritance reduces duplication and makes programs easier to maintain and reuse.

Polymorphism

Polymorphism means “many forms.” In Object‑Oriented Programming, it refers to the ability of a single action or message to behave in different ways. For example, one person can have multiple roles such as a father, husband, or employee, showing different behaviors in different situations. This concept is known as polymorphism.

Back to Blog

Related posts

Read more »

SOLID & OOP Design business case

Are OOP design principles useful, or do they just add unnecessary complexity? OOP Design Principles Encapsulation Encapsulation means bundling data with the met...

Features of Java

!Cover image for Features of Javahttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.am...

Classes and Inheritance

!Lahari Tennetihttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads...

JavaScript Objects with Methods

What Are Methods in Objects? A method is a function that lives inside an object. Think of an object like a toolbox, and methods are the tools inside it. javasc...