I'd like to know if Java is pure object oriented or not. Please explain it with example. I have goggled it, but I couldn't find the exact answer.
-
14You'd have to define the term "pure object oriented" in order to make the question answerable. – Jon Skeet Oct 11 '12 at 09:36
-
3I would really like to see an example of *pure object oriented programming language*. – Alvin Wong Oct 11 '12 at 09:39
-
Do you mean an *object based programming language* or an *object oriented programming language*? Because the prefix "pure" does not make any sense for the latter... – brimborium Oct 11 '12 at 09:41
-
2See http://stackoverflow.com/questions/974583/is-java-100-object-oriented?rq=1 ... summary: can't be answered without a good definition of what "pure object oriented" even means. – Joachim Sauer Oct 11 '12 at 09:42
-
1Whether it is or isn't, when is this ever relevant? – Vala Oct 11 '12 at 09:42
-
3@Thor84no For instance in an exam. :P – brimborium Oct 11 '12 at 09:43
-
Brother , IDEAL cases are just theoretical. IDEAL gas equation, ideal ohms law, and IDEAL OOPS. Java is Realistic OOPS.. :) :D – Mukul Goel Oct 11 '12 at 09:43
-
Also: see [this programming.SE question for an attempt at defining "pure OO"](http://programmers.stackexchange.com/questions/164570/formal-definition-for-term-pure-oo-language). – Joachim Sauer Oct 11 '12 at 09:43
-
@brimborium I rest my case. :P – Vala Oct 11 '12 at 09:44
-
Although java has primitive types, you can implement them as object. I think there is no language out there that is 100% object oriented... – Confuse Dec 11 '14 at 06:05
-
For comparison, the Smalltalk programming language basically has only two things: objects, and messages that are sent to objects. Essentially everything else is implemented by sending messages to objects. It has *no* "primitive" (non-object) types (nor any ability to operate on them). It doesn't even have things like if/then/else or loops built into the language--those are implemented as objects and messages. Even simple things like addition and subtraction are done by sending messages to objects. Compared to that, Java really isn't even particularly close to pure object orientation. – Jerry Coffin Feb 23 '15 at 18:30
-
Yes Java is purely object-oriented, please read the complete explanation https://programmingmitra.blogspot.com/2016/06/why-java-is-purely-object-oriented-or-why-not.html – Naresh Joshi Oct 15 '18 at 11:21
4 Answers
There are lot of arguments around whether Java is purely object oriented or not.
Java should be considered as purely object oriented language as it has wrapper classes.
So you can use Integer
, Float
etc. instead of int
, float
etc. (there are a total of eight primitive types).
But since Java has those eight primitive types, the critics will say Java is not purely object-oriented.

- 6,534
- 13
- 40
- 67
-
2
-
10What is "pure" object oriented? Can you explain? And even if it has wrappers, it still has types that are not objects which you can use with no problems. – m0skit0 Oct 11 '12 at 09:50
-
yes i can correct you. yes java has wrappers. but it has primitives as well. dont say.. that now java has wrappers.. so we can express integer,float etc as objects so java is now pure oo. thing is , yes wrappers are there.. but we can stil have int, float as primitives. so java is not purely object oriented. refer to update to my answer below. java isnt pure oo #fact.. if u feel otherwise , thats another story. – Mukul Goel Oct 11 '12 at 16:21
-
@Mukul Goel - You are seeing in from one side(primitive type) only. Will you not consider a java program pure-OO which uses Wrapper objects(Integer, Float etc) instead of int and float??? – Arun Kumar Aug 05 '13 at 08:30
-
@ArunKumar : yes I would consider that program a pure OO. But that is just one of the case and java allows us to use the primitives. Thus Java, as a language is not pure OO. – Mukul Goel Aug 05 '13 at 09:23
-
So you're basically saying that "according to [you]" Java is one thing, and according to everybody else it is another. So what is the point of this answer? – Lightness Races in Orbit Feb 23 '15 at 16:58
-
@BoundaryImposition : In a world of `supporters/advocates` and `criticits`, you can consider me in supporters / advocate club who think Java is Pure OO Language. – Arun Kumar May 30 '17 at 07:35
-
2
For example it contains 8 primitive data types.
For a language to be "pure oo" everything should exists as objects, but int
, float
, char
, .. etc are not objects in Java.
Here's an example:
int i = 42;
System.err.println(i.toString());

- 74,840
- 36
- 166
- 272

- 8,387
- 6
- 37
- 77
-
@MIkul Goel but java have wrapper classes for these data types primitives which convert thise into objects ..... – Oct 11 '12 at 09:40
-
1
-
1Yes, some would say we have wrappers. BUT we can use the primitive datatypes without the wrappers(i.e. not as objects).. OO says..everything should be treated as objects.. SO .. NO pure OO.. :-) – Mukul Goel Oct 11 '12 at 09:42
-
And what is the difference between a primitive type and a type without the function member toString or any other function member? For example, in C++, a object is "a region of storage". So, under this definition, an interger is an object. What is the (unambiguous) definition of object? – ABu Feb 19 '14 at 13:18
-
-
1@MukulGoel Good point, but I think if a primitive type is an instance of a class or not, is transparent for you. So, I don't see any difference from a programmer's point of view. I come from the C++ world, and an instance of a class with implicitly default constructor, implicitly copy and move constructors/assignment operators (a POD class), and POD subobjects, has no differences with primitive types from a point of view of performance, except for the fact this class is a compoud type (it requieres more storage and time to reserve that storage). – ABu Feb 19 '14 at 16:21
Java is a OOP language and it is not a pure Object Based Programming Language. Many languages are Object Oriented. There are seven qualities to be satisfied for a programming language to be pure Object Oriented. They are:
- Encapsulation/Data Hiding
- Inheritance
- Polymorphism
- Abstraction
- All predefined types are objects
- All operations are performed by sending messages to objects
- All user defined types are objects.
Java is not because it supports Primitive datatype such as int, byte, long... etc, to be used, which are not objects. Contrast with a pure OOP language like Smalltalk, where there are no primitive types, and boolean, int and methods are all objects.
This answer is taken from http://wiki.answers.com/Q/Why_is_Java_not_a_pure_OOP_Language
-
1That's not a trustable reference and does not cite its references either. Those 7 qualities, who says so? – m0skit0 Oct 11 '12 at 09:45
-
1
no it has primitive data types, thus i would say its not completely object oriented. i think Smalltalk can be considered pure object oriented than java.
Straight from wiki
Smalltalk is a "pure" object-oriented programming language, meaning that, unlike Java and C++, there is no difference between values which are objects and values which are primitive types. In Smalltalk, primitive values such as integers, booleans and characters are also objects

- 1
- 1

- 45,977
- 8
- 87
- 106
-
-
yes, it does not. i meant small talk is pure object oriented than java\ – PermGenError Oct 11 '12 at 09:47
-
-
@m0skit0 did you check my quoted text from wiki ?? .. i am no OOP guru, nor i know smalltalk. :P – PermGenError Oct 11 '12 at 09:50
-
That's why in Wikipedia they put **"pure"** (between quotes)... because you can't measure such thing, and as such, you cannot say if a language is more/less pure object oriented than another one. And anyway, what does "pure object oriented" mean? – m0skit0 Oct 11 '12 at 09:55
-
@m0skit0 thanks for the info, tbh, i never really came across this question before. the only thing i understand from the wiki is in smalltalk which is considered as "pure"OO language there is no place for primitive which java supports, again you can say that java has wrappers which can be used in place of primitives. i think you are right, measuring "pure"OO" is kinda stupid .. :P – PermGenError Oct 11 '12 at 10:01
-