Day 5 - Why is java not a Pure Object-Oriented language?
C K Sanjay Babu
Posted on May 5, 2022
For any programming language to be called a pure object-oriented language, it should satisfy all the 7 rules below :
- Encapsulation/Data Hiding
- Inheritance
- Polymorphism
- Abstraction
- All predefined types are objects
- All user-defined types are objects
- 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.
💖 💪 🙅 🚩
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.