Is Java pure OOPS or not?

Java is pure object oriented or not? if not why?

Pure Object Oriented Language is the language that utterly supports everything inside a program as object. Any language must fulfil these seven features to be pure OOPS –

  1. Polymorphism
  2. Data Hiding /Encapsulation
  3. Abstraction
  4. Inheritance
  5. All user-defined types are objects.
  6. Every operation is performed by sending messages to objects.
  7. All predefined types are objects.

Java supports property 1, 2, 3, 4 and 7 points mentioned above but fails to support property 5 and 6. Java language is not a Pure Object Oriented Language as it contains these properties which can be explained with following three reasons:

1) It does not support Multiple inheritance.

Various programming languages support multiple inheritance like C++  while Java does not support it. Due to multiple inheritance in java problem of ambiguity occurs, which is why, java does not allow multiple inheritance.

Example- diamond problem that occurs while using multiple iJavainheritance.

2) It allows the use of primitive data types which are not objects.

The object of class defines the behaviour of all Java objects. However, it does not define the behaviour of all Java data structures.

What’s the reason?

Because all Java data structures are not objects. A few of them are primitive values that can be stored in object variables but are not objects themselves. Primitive types should be well-known from Java interfaces or classes, which are types of object only. Hence, the type of a variable can be a primitive type or an object type, which can be an interface or a class.

3) It allows static methods to call without creating the instance.

Java provides a class, which is user-created datatype.

In Java, access specifier called ‘static’ which is also one of the keywords in the language. Due to which, when you declare a member of a class static, it can be referred not as a “property” of an instance of the class but as a “property” of the class itself.

Therefore, if I have a method that is linked with the class more than an instance of the class, it is generally declared static.

I Hope this article will be helpful for you. This question is important and mostly asked in interview questions.

Happy Programming.

Leave a Reply

Your email address will not be published. Required fields are marked *