What is object-oriented programming and what are its four pillars?

Computer Science

ScanSolve AI Answer

OOP organizes code around objects (data + methods). Four pillars: 1) Encapsulation: bundling data with methods that operate on it, hiding internals (private/public). 2) Abstraction: showing only essential features, hiding complexity. 3) Inheritance: creating new classes from existing ones (parent → child). 4) Polymorphism: same method name, different behavior (overriding in subclasses). Example: Animal class with speak() → Dog.speak() returns "Woof", Cat.speak() returns "Meow".

Was this helpful?

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question