← Back to libraryQuestion 3 of 273
JavaIntermediate

OOP Principles: Pure vs Non-Pure

📖 Detailed Explanation:

Java follows four pillars of OOP: Encapsulation (hiding internals), Abstraction (exposing only necessary features), Inheritance (reusing code), and Polymorphism (objects behaving differently). However, Java is not '100% pure' OOP because it supports primitive data types like int, long, and boolean, which are not objects. A pure OOP language would treat every single piece of data as an object.

🌍 Real-World Example:

A 'Car' class inherits from 'Vehicle' (Inheritance), hides its engine implementation (Abstraction), keeps its oil level private with getter/setter (Encapsulation), and changes speed differently if it's an 'ElectricCar' or 'GasCar' (Polymorphism).

🎯 Scenario-Based Interview Question:

Can we call Java a pure Object Oriented language? Justify your answer with examples.