Introduced to this world in 1995 by Sun Microsystems, Java is a programming language built around OOP. In fact, Java is touted to be the ideal way to learn OOP. There is a huge fan base for Java and considered to be evergreen and one of the most preferred OOP languages in the IT world. Then what is this buzz surrounding Java that it is not purely object-oriented programming language? Let’s look at the claim closely and figure out the truth behind it.
Perceptions apart, for Java programming online training, consider H2K Infosys, the market leader in providing IT training to learners across the world.
Principles of OOP
A pure OOP Language is supposed to follow the below-mentioned principles
- Encapsulation – This property dictates that all the data is hidden under a specific head.
- Polymorphism – This concept of OOP that enables the existence of a single entity in multiple forms. This can be achieved through method overloading and method overriding.
- Inheritance – This concept ensures that an object acquires all the properties of a parent class which it extends. Instead of creating a new class, all the properties of the parent class such as methods and variables can be extended to the child class and can be used.
- Abstraction – By virtue of this property of OOP, only the necessary data is exposed to the end-user, hiding the unconcerned data from them. This is achieved through interfaces and abstract classes.
- All predefined types are objects
- All user-defined types are objects
- All operations are performed by sending messages to objects
So, is Java not a pure OOP language?
Point 5 fails: Smalltalk is a pure OOP language as all the predefined data types such as integers, Booleans, and characters are also objects unlike in Java. In Java, the primitive data types like int, char, long, bool, float, are not objects but the wrapper classes Integers, Character, and Float are. These wrapper classes have the right to convert primitive data types to objects. This means that all the predefined (primitive) types are not objects. This contradicts point 5 of OOP principles.
Point 7 also fails in Java: Whenever a class is declared as static, it need not be instantiated in Java. The entities in that class can be accessed using the class name (.)variable without the use of the object of a static class. This means point 7 is contradicted.
Verdict: When two of the principles of pure object-oriented programming concepts fail, Java is not considered pure OOP language.
Enroll for our 80+ hours comprehensive program at www.h2kinfosys.com for Java online course certificate.