What is abstraction in OOP?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid OOP Concepts basics — a prerequisite for any developer role.

Answer

Abstraction means showing only the essential features of an object while hiding the unnecessary implementation details. It focuses on WHAT an object does rather than HOW it does it — providing a simplified interface to complex underlying code. Real-world analogy: a car's steering wheel abstracts complex steering mechanisms; you don't need to know about power steering hydraulics to drive. A TV remote abstracts the complex electronics — you just press buttons. In OOP, abstraction is achieved through: (1) Abstract classes: cannot be instantiated; define partial implementation with abstract methods that subclasses must implement: abstract class Shape { protected String color; // Constructor: public Shape(String color) { this.color = color; } // Abstract method -- no implementation: public abstract double area(); public abstract double perimeter(); // Concrete method -- shared implementation: public void displayInfo() { System.out.println("Shape: " + getClass().getSimpleName() + ", Color: " + color + ", Area: " + area()); } }; (2) Interfaces: pure abstraction — only method signatures, no implementation (in Java before default methods): interface Printable { void print(); void printToFile(String path); } class Document implements Printable { public void print() { /* implementation hidden */ } public void printToFile(String path) { /* implementation hidden */ } }. Difference from encapsulation: Encapsulation = hiding data and bundling; Abstraction = hiding complexity and showing only interface. They complement each other but are distinct concepts.

Common Mistake

Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your OOP Concepts experience.