File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Is Java Pure Object Oriented? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is Java Pure Object Oriented?" Watch "Is Java Pure Object Oriented?" New topic
Author

Is Java Pure Object Oriented?

Umesh Vajpai
Greenhorn

Joined: Mar 14, 2010
Posts: 26
Hi,

Could anyone tell me please whether JAVA is purely object oriented or not?In any answer please justify.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

Yes, it is.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Sateesh.B Kumar
Greenhorn

Joined: Sep 05, 2007
Posts: 6
No it isn't. Not all types are reference types in Java. There are primitive types like "int", "float" etc.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

"Sateesh Kumar.B", please check your private messages regarding an important administrative matter from JavaRanch.
Umesh Vajpai
Greenhorn

Joined: Mar 14, 2010
Posts: 26
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

Joined: Mar 14, 2010
Posts: 26
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

Did you see the link I provided?
Umesh Vajpai
Greenhorn

Joined: Mar 14, 2010
Posts: 26
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

For more details, have a look at the Object Orinted Concepts.
All of these concepts are implemented in Java.
Umesh Vajpai
Greenhorn

Joined: Mar 14, 2010
Posts: 26
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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Sep 05, 2007
Posts: 6
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

Joined: Aug 16, 2005
Posts: 14268
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Sateesh.B Kumar
Greenhorn

Joined: Sep 05, 2007
Posts: 6
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

Joined: Mar 14, 2010
Posts: 26
Hi Sateesh,

I even think this.Thanks to put light on this question.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
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

Joined: Oct 02, 2003
Posts: 11402
    
  16

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...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...


BEE MBA PMP SCJP-6
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11402
    
  16

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 04, 2008
Posts: 50
Ruby is one of the pure OOPS language although multiple inheritance is not there!!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Multiple inheritance can be realized in different ways, though, not just through direct "classical" inheritance--consider what mixins give you.
Gauri Patil
Greenhorn

Joined: Mar 19, 2010
Posts: 2
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

Joined: Sep 29, 2008
Posts: 12617

Java's operators aren't objects.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42272
    
  64
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.


Ping & DNS - my free Android networking tools app
Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
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.


Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42272
    
  64
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

Joined: Aug 30, 2009
Posts: 217
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
Marshal

Joined: Mar 22, 2005
Posts: 42272
    
  64
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 08, 2003
Posts: 7
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


Anju
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Multiple inheritance is not intrinsic to OOP, and is not necessary for a language to be OOP.
arun r mehta
Ranch Hand

Joined: Mar 08, 2010
Posts: 38
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....


-arun


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 17, 2010
Posts: 1051

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


SCJP6.0,My blog Ranchers from Delhi
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11402
    
  16

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

Joined: Mar 17, 2010
Posts: 1051

so the conclusion of above discussion is
no language in this world is pure object oriented............
as every language contain operater like +,-,*,= etc................
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Java Pure Object Oriented?