Computer ScienceProgrammingMedium

Abstraction (OOP)

Also known as:data abstractionabstract modelling

Abstraction in OOP is the principle of exposing only the essential features of an object to the outside world while hiding the complex implementation details. It is achieved through abstract classes and interfaces, which define a contract specifying what methods a class must implement without dictating how they are implemented. Abstraction reduces complexity for the programmer using the class and allows internal implementations to change without affecting dependent code.

Abstract Class vs Interface — Key Differences

FeatureAbstract ClassInterface
Can have constructor?YesNo
Can have concrete methods?YesYes (default methods in Java 8+)
Multiple inheritance?No (single class only)Yes (multiple interfaces)
Access modifiers on methods?AnyPublic only (implicitly)
Use casePartial implementation sharedPure contract / capability
Example (Java)abstract class Shapeinterface Drawable

Interactive Tools

W3Schools – Java Abstraction

Open Tool

Codecademy – Abstract Classes

Open Tool

Brilliant – Abstraction in OOP

Open Tool
Diagram illustrating abstraction by showing a user interacting with a simplified interface hiding complex logic

Wikimedia Commons, CC BY-SA

Related Terms

Computer Science

Encapsulation

Encapsulation is the OOP principle of bundling an object's data (attributes) and the methods that operate on that data into a single unit (a class), while restricting direct external access to the internal state. By declaring attributes as private and exposing them only through public getter and setter methods, encapsulation enforces data integrity and hides implementation details. This protects objects from unintended interference and simplifies maintenance since internal changes do not affect external code.

Computer Science

Interface (OOP)

An interface in OOP is a fully abstract type that defines a set of method signatures (a contract) that any implementing class must fulfil, without specifying how those methods work. Interfaces enable multiple inheritance of type in languages like Java and C#, allowing a class to implement several interfaces simultaneously. They promote loose coupling in software design by allowing different classes to be used interchangeably when they implement the same interface.

Computer Science

Object-Oriented Programming

Object-Oriented Programming (OOP) is a programming paradigm that organises software design around data, called objects, rather than functions and logic. Each object encapsulates data (attributes) and behaviour (methods), and objects interact with one another to build complex systems. The four core principles of OOP — encapsulation, inheritance, polymorphism, and abstraction — promote code reusability, modularity, and maintainability.

From Latin "abstractus", past participle of "abstrahere" meaning "to draw away". In philosophy, abstraction involves removing specific details to consider general properties. The concept was applied to programming by Dijkstra and Hoare in the 1970s in discussions of structured programming and modular design.

abstractionoopabstract-classinterfacedesign