Is Java Object Oriented?

We say java is not purely object oriented since primitive data types are not objects. But in the lower code, how does an object hold a primitive data type?

public class Test{ public Object meth(Object obj){ System.out.println(obj instanceof Object);//It prints true System.out.println("Value = "+obj);//It prints "Value = 1" return obj; } public static void main(String[] args) { int a = 1; System.out.println(new Test().meth(a)); } } 
+4
source share
12 answers

It is called autoboxing . Basically, the Java compiler converts primitive data types to objects for you when you use them in a context that requires them to be objects.

+8
source

Since Java has 8 primitive types, it is not a purely object-oriented language. But primitive types make Java more efficient.

+4
source

Java is purely object oriented because every thing in Java is treated as an object. However, Java is not purely object oriented, because it supports primitive data types that violate OOP philosophy.

+3
source

Because primitive types are automatically loaded (in java terms) into object types. For example, int is authenticated to an Integer object.

+2
source

Yes, you're right ... Java is not pure Object Oriented because it supports a primitive data type, such as int, byte, long ... etc., to be used, which are not objects ...

Over the concept, this is called autoboxing .

Autoobject: Autoobject is an automatic conversion that the Java compiler does between primitive types and the corresponding wrapper classes of objects

Source: http://docs.oracle.com/javase/tutorial/java/data/autoboxing.html

+2
source

ava is not pure Object Oriented because it supports a primitive data type such as int, byte, long its True, but we have classes like whole classes of characters in java, converting from primitive to these classes when it is implicitly called autoboxing . this can also be done explicitly.

0
source

Java is not a purely object oriented language for the following reasons.

  • Java supports primitive data types.
  • Java is supoort static, and they belong to a class not for an object.
  • java supports enumerations.

And as in OOP, Everything must be an object.

0
source

In your context, this is called auto boxing , because you simply pass a non-primitive value to the Object argument, it will automatically convert it to an object type.

0
source

Because if using java primitives is not purely object oriented. For more information, follow this link.

0
source

Java is not a purely object-oriented programming language; to satisfy a programming language is object-oriented, it satisfies the concepts of Encapsulation / Hiding data inheritance Polymorphism abstraction All predefined types are objects All operations are performed by sending messages to objects All user types are objects. these are things. some say that java supports a primitive data type such as int, float, therefore it is not object oriented, but although it is based on the Wrapper INTGER class, FLOAT things are java suppourt static its keyword does not follow oops, therefore java is not purely object oriented language

0
source

No. This is not because data types are not classes, unlike C #, where data types are .yes classes wrapper classes are introduced later in java, but there is the concept of autoboxing and boxing, which makes the situation difficult.

0
source

Yes. Java is not purely object oriented since it contains primitive data types that are not objects. In the case of your script, you pass the int value to the function. The reason for this is because autoboxing . The following link provided may help you understand autoboxing. Press here

0
source

All Articles