Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Java Pure Object Oriented?

 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could anyone tell me please whether JAVA is purely object oriented or not?In any answer please justify.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is.
 
Sateesh.B Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it isn't. Not all types are reference types in Java. There are primitive types like "int", "float" etc.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sateesh Kumar.B", please check your private messages regarding an important administrative matter from JavaRanch.
 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:Yes, it is.


Hi Deveka Cooray,


Please justify your answer.I am confused.someone saying yes and someone no.I need justification.
 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sateesh Kumar.B wrote:No it isn't. Not all types are reference types in Java. There are primitive types like "int", "float" etc.



Hi Sateesh,


Please justify it.I am totally confused.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you see the link I provided?
 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:Did you see the link I provided?


Hi Deveka,

I have gone through but where i get answer of my question?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For more details, have a look at the Object Orinted Concepts.
All of these concepts are implemented in Java.
 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:For more details, have a look at the Object Orinted Concepts.
All of these concepts are implemented in Java.


Hi Deveka,

I know all OOP concepts.As it is noted in every book that java is purely object oriented but it has primitive types and that is why i having confusion regarding.Are you getting me?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These concepts define whether a language is Object Oriented or not. Since all of the OOP concepts are implemented in Java, it is an OOP language. Being OOP does NOT imply it shouldn't provide additional features, concepts, etc.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Umesh Vajpai wrote:Could anyone tell me please whether JAVA is purely object oriented or not?


Devaka answared already in his first post.

@ Sateesh: probably you are confused about the question Is Java *100 % * Pure Object Oriented ? . it is different from what Umesh asked.
 
Sateesh.B Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote
@ Sateesh: probably you are confused about the question Is Java *100 % * Pure Object Oriented ? . it is different from what Umesh asked.


I thought pure implies 100%.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15437
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "purely object oriented" mean exactly? Are there any languages that are 100% purely object oriented?

By the way, this question is a frequently asked question on the forum here.
 
Sateesh.B Kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think existence of primitive types doesn't make Java a pure (100%) object oriented language. Once a varaibles is declared to be of primitive type
it cannot be used polymorphically. I have read that Smalltalk is a much more object oriented than Java, but having no experience with Smalltalk I don't know how Smalltalk is better Object Oriented than Java.
 
Umesh Vajpai
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sateesh,

I even think this.Thanks to put light on this question.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49755
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please search. This question comes up frequently and the usual conclusion is . . . "it all depends what you mean by 100% purely object-oriented."
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people think that to be "pure OO", you can't have operators either. EVERYTHING would be a method. you would never do

Integer A = 7;

because '=' isn't an object. instead you would do

Integer A.setValue(7);

of course, now you have the problem that '7' isn't an object, but an integer value, so I don't know how you get around that...
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what ways is "purity" important (using no primitive
types)? I understand the discussion but wonder why
it seems so important to some. Please explain.

Jim ... ...
 
Henry Wong
author
Marshal
Pie
Posts: 21386
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim Hoglund wrote:In what ways is "purity" important (using no primitive
types)? I understand the discussion but wonder why
it seems so important to some. Please explain.


It's important to theorists -- of which, I am way too pragmatic to be one. To me, what is important is how a feature is useful -- meaning to be used. To argue that a feature is within a bounds of a definition is kinda silly to me. And to argue that something is not within the bounds because it has a feature that is not within the bounds of a definition...

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's also important to college professors who are too lazy to come up with useful, meaningful lessons rather than relying on quick, easy topics like this.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:Are there any languages that are 100% purely object oriented?

IMO, yes (Java not fitting my mental model of one, however).
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:of course, now you have the problem that '7' isn't an object, but an integer value, so I don't know how you get around that...

Sure it is; 7.times { |n| puts n }

In any case, it's not *necessarily* important, as obviously a lot of work can be done in non-OOP languages, and has for decades. Where it gets interesting is discussing the relative expressiveness of languages, their ability to encapsulate abstractions, the presence (or lack thereof) of a MOP, and so on.

OOP sometimes gets a bad rap, but that's generally by people who use Java as their example language. Patterns, for example, often disappear into the language itself, or are used so naturally that you don't even know it's a capital-p Pattern. Some folks also have difficulty understanding there are different models of OOP (prototypal, like Self or JavaScript; multiple dispatch, like CLOS) because they're locked into a narrow understanding of what OOP really is.

As Kay says, C++ is *not* what he had in mind ;)
 
Ritesh Pareek
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ruby is one of the pure OOPS language although multiple inheritance is not there!!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multiple inheritance can be realized in different ways, though, not just through direct "classical" inheritance--consider what mixins give you.
 
Gauri Patil
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes java is pure OO,BUt in your pgm 'A' OR '7' is not objects but these are variables.objects are those on which behaviour or methods are pperated
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java's operators aren't objects.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:What does "purely object oriented" mean exactly? Are there any languages that are 100% purely object oriented?

+1. Without a definition of what "purely OO" means, this question -and any answer to it- is meaningless. Languages exist that are decidedly more OO than Java (Smalltalk, for example), so I'd argue that Java most certainly is not pure OO.
 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Java is a pure Object Oriented Language.

Everything is defined under Classes and no data is moved freely. And these Objects can only deal with the Classes.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod Vijay wrote:Everything is defined under Classes and no data is moved freely.

That'll be news to anyone who's ever used an "int".
 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Java is a pure object oriented language.
Everything is written under classes, no data can flow freely beyond classes.
Only Objects can access it.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod Vijay wrote:Everything is written under classes

So where is "int" in the class hierarchy? (Note that auto-boxing does not make a primitive an object.)
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod Vijay wrote:Everything is defined under Classes

Except for the primitives. And operators. And it's not really "regular" in how it treats things (consider the Arrays class, instead of just operating on arrays, you have to multiple-dispatch).

OOPness is a continuum. When you look at a stronger OO language it's obvious Java isn't on that level. Does that mean it's not "pure" OOP? Not sure--but it's certainly weaker than some.
 
Anju Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with the experts here on Java.
Java is Object oriented, but for sure not 100% object oriented based on not supporting multiple inheritance(supports thru interface but not implementation wise), allowing primitive data type(s). C++ is more % of object oriented than Java.
Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multiple inheritance is not intrinsic to OOP, and is not necessary for a language to be OOP.
 
arun r mehta
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is pure object oriented language..

The reason is simple for each instance of JVM thier is atleast 1 object in the memory and also primitives cannot exist without existence of their containing object...

so in java without object you cannot do anything....
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saying that primitives can't exist without a containing object begs the question--primitives aren't objects, so any question of "purity" has already been answered: if an object can hold something that *isn't* an object, then non-objects must exist, destroying any notion of purity.

That aside, I don't think your answer really addresses the question--we're talking about the *language*, not its runtime environment. In an OOPL continuum, Java does better than some, worse than many.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me JAVA is not a pure oop Language ,because java contains primitive datatypes thats not an Objects."

however the language which are pure object oriented are Smalltalk, Eiffel and Simula
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shanky sohar wrote:however the language which are pure object oriented are Smalltalk, Eiffel and Simula

Smalltalk, Eiffel and Simula all contain operators ( + comes to mind). Operators are not objects. Therefor, Smalltalk, Eiffel and Simula are not pure OO.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so the conclusion of above discussion is
no language in this world is pure object oriented............
as every language contain operater like +,-,*,= etc................
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic