c2cedge
LibraryCS Fundamentals › Ch 16
CS Fundamentals · D — Object-Oriented Programming

OOP Concepts & the Four Pillars

OOP models software as interacting objects. The four pillars — encapsulation, abstraction, inheritance, polymorphism — are the most certain interview question of all.

Test weight: Very highAsked by: All recruitersDifficulty: Easy–Medium

Object-Oriented Programming organises software around objects — bundles of data (attributes) and behaviour (methods) — rather than around functions and logic alone. A class is the blueprint; an object is an instance of it. The paradigm rests on four pillars that every interviewer will ask you to name and explain.

Class vs object

A class is a template defining attributes and methods; an object is a concrete instance with its own data. 'Car' is a class; your specific red car is an object. You can create many objects from one class.

The four pillars

PillarMeaning
Encapsulationbundle data + methods, hide internal state behind an interface
Abstractionexpose what an object does, hide how it does it
Inheritancea class derives attributes/methods from a parent class
Polymorphismone interface, many forms (same call, different behaviour)
⚡ The edge
  • Memorise the four pillars as A-PIE: Abstraction, Polymorphism, Inheritance, Encapsulation — then give a one-line example of each.
  • Encapsulation vs abstraction is the trap pair: encapsulation hides data (private fields + getters/setters); abstraction hides complexity/implementation (you call drive(), not the engine internals).
Worked example
'What are the four pillars of OOP?'
  1. Name them: encapsulation, abstraction, inheritance, polymorphism.
  2. Give a one-liner each: encapsulation bundles and hides data; abstraction hides implementation; inheritance reuses a parent's members; polymorphism lets one interface take many forms.
  3. Anchor with an example: a Shape base class with area(), overridden by Circle and Square (polymorphism + inheritance).
Worked example
'What is the difference between a class and an object?'
  1. A class is a blueprint that defines structure and behaviour but holds no data by itself.
  2. An object is an instance of that class, occupying memory and holding actual values.
  3. Analogy: the class is the architectural plan; each house built from it is an object.
⚠ Watch out
  • Don't confuse encapsulation (hiding data behind an interface) with abstraction (hiding implementation complexity).
  • A class doesn't consume object memory until you instantiate it.
  • OOP's benefits — reusability, maintainability, modelling real entities — are worth stating when asked 'why OOP'.
Practice this — take a timed mock →
1,300+ questions, scored, with a weak-area report.
Know who's ready. Not who finished.
HomeLibraryPrivacyTerms