Is Java an Object-Oriented Language or Not?

Java is not a pure object-oriented language. Don’t believe me?

Well, it is the bitter truth of the IT industry. OOPs introduces seven concepts; any programming language should implement all seven of those to be considered an object-oriented language.

  1. What are those seven concepts?
  2. How many can Java implement?
  3. What is the reason behind this?

All of these questions are answered below; let’s find out.

Why Java is not object oriented langauge

Introduction to Object-Oriented Language

An object-oriented programming paradigm is based on the concept of classes and objects. An object contains data (in the form of fields) and code (in the form of methods) and classes are the blueprint of the object.  A purely Object-Oriented Programming Language has everything inside the program as objects. It doesn’t support primitive data types(like int, char, bool, and so on.).

The following are the seven qualities to be satisfied for a programming language to be a pure Object-Oriented Language. They are:

  • Abstraction
  • Polymorphism
  • Encapsulation
  • Inheritance
  • All predefined types must be objects
  • All user-defined types must be objects
  • Every operation on objects must be done with the help of methods.

Master the concept of Polymorphism in Java in 7 Mins.

Reasons Why is Java an Object-Oriented Language?

In the following qualities, Java supports ‘Abstraction, ‘Polymorphism’, ‘Encapsulation’, ‘Inheritance’, and ‘all user-defined types must be object’. But it fails to support ‘all predefined types must be objects’ and operations on objects must be done with the help of methods.

Java language is not a pure Object-Oriented Language because it has the following properties:

1. Primitive Data Type

An example of a purely Object-Oriented Language is Smalltalk, it is unlike C++ and Java. In Java, we treat predefined data types as non-objects but the primitive data types in Java are treated as objects in Smalltalk.

Join DataFlair on Telegram

Example –

  int number = 10;
  System.out.print(number);

2. The static keyword

In Java, a class declared as static can be used without the use of an object. We cannot call that function or variable using a dot(.) if we are using a static variable or a static class.

3. Wrapper Class in Java

With the help of the Java wrapper class, we can convert primitives into objects and objects into primitives. In Java, we can use Integer, Float, Double instead of int, float, etc. We don’t need to call the method to communicate with the objects.

For example-

String message = "Data" + "Flair" ;

By using Wrapper classes Java does not become a pure OOP language, as it will use the operations like Autoboxing and Unboxing. So even if we create Integer instead of int and do any mathematical operation, it will still use primitive type int only.

package com.dataflair.packageprogramdemo;

public class WrapperClass {

  public static void main(String[] args)
  {
    Integer operand1 = new Integer(10);
    Integer operand2 = new Integer(20);
    Integer operand3 = new Integer(30);
    Integer operand4 = new Integer(operand1.intValue() + operand2.intValue()+ operand3.intValue());
    System.out.println("Addition of three numbers is : "+ operand4);
  }
}

Output-

Wrapper-class-example

Summary

These are the reasons which show, Java is not a pure object-oriented programming language. Despite the different reason, Java is being 1st choice of programmers among all languages. So, what are you waiting for?

Get the Free Tutorial series of Java by DataFlair from freshers to experienced and master Java within a month!

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.