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

sanjaybabu

C K Sanjay Babu

Posted on May 5, 2022

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

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.

💖 💪 🙅 🚩
sanjaybabu
C K Sanjay Babu

Posted on May 5, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related