Why Java is not a Pure or Fully Object-Oriented Programming Language?

In this article, we will take a look into why Java is not a 100% fully OOPS (Object Oriented Programming) language?

Seven Qualities

There are seven qualities to be satisfied for a programming language to be pure Object Oriented:

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 supports qualities 1, 2, 3, 4, and 6 but fails to support qualities 5 and 7 as shown in the below diagram:


Why Java is not a Pure or Fully Object-Oriented Programming Language?

Well, Java is not a pure OOP language due to two reasons:

The first reason is that the Object-oriented programming language should only have objects whereas java contains 8 primitive data types like char, boolean, byte, short, int, long, float, double which are not objects. These primitive data types can be used without the use of any object. 

For example:
public class IsJavaFullyOOPS {
    public static void main(String[] args) {
        int i = 10;
        byte b = 20;
        short s = 30;
        long l = 100L;
        double d = 100.10;
        float f = 200f;
        boolean flag = true;
        char c = 'R';
        System.out.println(i);
        System.out.println(b);
        System.out.println(s);
        System.out.println(l);
        System.out.println(d);
        System.out.println(l);
        System.out.println(d);
        System.out.println(f);
        System.out.println(flag);
        System.out.println(c);
    }
}
Output:
10
20
30
100
100.1
100
100.1
200.0
true
R
Even using Wrapper classes does not make Java a pure OOP language, as internally it will use the operations like Unboxing and Autoboxing. So if you create instead of int Integer and do any mathematical operation on it, under the hoods Java is going to use primitive type int only.

The second reason is related to the static keyword. In a pure object-oriented language, we should access everything by message passing (through objects). But java contains static variables and methods which can be accessed directly without using objects. 

For example:
public class IsJavaFullyOOPS {
    private static String message = "hello";
    public static void main(String[] args) {
        
        // calling message instance variable without object
        System.out.println(message);
        
        // calling demo static method without object
        demo();
    }
    
    private static String demo(){
        return "hello from method";
    }
}

YouTube Video


Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours


Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course