What are 4 types of OOPS?

In Object-Oriented Programming (OOP), there are four fundamental concepts that form the foundation of the paradigm. These concepts are:

1. Encapsulation

Encapsulation is the concept of bundling data (attributes) and methods (functions) that operate on the data into a single unit, known as a class. It restricts direct access to some of the object's components, which helps to protect the integrity of the data.

  • Example: In a class representing a bank account, the balance would be a private member, and the class would provide public methods to deposit or withdraw money, ensuring that the balance cannot be modified directly.

2. Inheritance

Inheritance allows a new class (derived class) to inherit properties and behaviors from an existing class (base class). This promotes code reusability and establishes a hierarchical relationship between classes.

  • Example: A class Animal could be a base class, while classes Dog and Cat could be derived classes that inherit common attributes and methods from Animal.

3. Polymorphism

Polymorphism enables objects of different classes to be treated as objects of a common base class. It allows methods to be invoked on objects of derived classes through base class references or pointers, enabling dynamic method resolution.

  • Example: If both Dog and Cat classes have a method speak(), a base class pointer can call speak() on an object of either derived class, executing the appropriate method based on the actual object type.

4. Abstraction

Abstraction involves hiding the complex implementation details and exposing only the necessary features of an object. It allows focusing on what an object does instead of how it does it, often achieved using abstract classes and interfaces.

  • Example: A class Shape might define an abstract method draw(), while derived classes like Circle and Square provide specific implementations of how to draw those shapes.

Conclusion

These four concepts—encapsulation, inheritance, polymorphism, and abstraction—are integral to OOP, allowing for better data management, code organization, and software development practices.

Sources

TAGS
Coding Interview
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
What is 100K coding challenge?
What is the simplest way of doing a recursive self-join in SQL Server?
What is the best certification for a software engineer?
What is stack structure?
What is polymorphism, what is it for, and how is it used?
Which framework is better for frontend?
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.6
(3,192 learners)
Discounted price for Your Region

$123

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.