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– Jon Skeet2012-10-11 09:36:40 +00:00Commented Oct 11, 2012 at 9:36
-
3I would really like to see an example of pure object oriented programming language.Alvin Wong– Alvin Wong2012-10-11 09:39:47 +00:00Commented Oct 11, 2012 at 9:39
-
2See stackoverflow.com/questions/974583/… ... summary: can't be answered without a good definition of what "pure object oriented" even means.Joachim Sauer– Joachim Sauer2012-10-11 09:42:05 +00:00Commented Oct 11, 2012 at 9:42
-
1Whether it is or isn't, when is this ever relevant?Vala– Vala2012-10-11 09:42:51 +00:00Commented Oct 11, 2012 at 9:42
-
3@Thor84no For instance in an exam. :Pbrimborium– brimborium2012-10-11 09:43:05 +00:00Commented Oct 11, 2012 at 9:43
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.
8 Comments
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());
6 Comments
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
2 Comments
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