Day 5 - Why is java not a Pure Object-Oriented language?

Sanjay Babu's photo
Sanjay Babu
·May 5, 2022·

For any programming language to be called a pure object-oriented language, it should satisfy all the 7 rules below :

  1. Encapsulation/Data Hiding
  2. Inheritance
  3. Polymorphism
  4. Abstraction
  5. All predefined types are objects
  6. All user-defined types are objects
  7. All operations performed on objects must be only through methods exposed to the objects.

Java fails the rule no-5 and 7.

Why java fails the "All predefined types are objects" rule?

We have primitive data types - boolean, byte, char, int, float, double, long, short which are predefined types but not objects.

Why java fails the "All operations performed on objects must be only through methods exposed at the objects" rule?

It's due to the static keyword. When a variable is declared as static, they become class-level elements instead of instance variables. These static variables are accessible directly with the class name and can be used without the objects.

 
Share this