This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Is Java Object oriented language? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Is Java Object oriented language?" Watch "Is Java Object oriented language?" New topic
Author

Is Java Object oriented language?

Prabhjyot Singh
Greenhorn

Joined: Dec 28, 2000
Posts: 22
Hi All,
1.Java does not have everything as object (e.g primitives,not instances of their corresponding wrapper classes).
So is java an OO language?

2.Does concept of inheritance go against OO since child class inherits all members of it's parent class because in this case parents class's abstraction is broken.
Ta
Prabhjyot Singh Bhatia
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Prabhjyot,
Java is known as a "hybrid" language - not pure OO - because it has - as you mention - "primitive" data types. By the same token, C++ is also known as a "hybrid" language. On the other hand, smalltalk is a "pure" object oriented language since <em>everything</em> is an object and there is no concept of data type. However, smalltalk also has inheritance. As far as I know, inheritance is one of the things that makes an object-oriented language "object-oriented", and smalltalk - being the first OO language - in defining inheritance, gives me the impression that inheritance does not "go against OO".


Hope this has helped you,

Avi.
shailesh sonavadekar
Ranch Hand

Joined: Oct 12, 2000
Posts: 1874
Java is definitley object oriented language. Yaah , it is true that it is hybrid of many oo language. But , one should not forget that it has taken best from all the oo language. Java has also done great job by removing the features that were causing many problems to programmers.
The Purest form of OO language is SmallTalk. In that language , everything is object. But , that has got it's demertits also.
Please see why the wrapper classes are used in java. Every language has got its purpose & it is designed according to that.
In oops , you have greater advantage achieved through reusability. Through inheritance , you are utilizing the things that are already available.There is no point in writing which is already available. So , inheritance is one of the cornerstones of oops. How inheritance can go against oops ?
Am I interpereting your question correctly ? Please let me know.
I hope this is useful.
Shailesh.
Prabhjyot Singh
Greenhorn

Joined: Dec 28, 2000
Posts: 22
Avi and Shailesh,
1.Every class without exception should have all member variables private.But even private instance members variables of parent class ARE inherited by child classes, although you can not access those variable with child object's handle directly but any method/member function can use them.So inheritence does break OO abstraction of super types by the sub types.
2.Does smalltalk support M-inheritance
Ta,
prabh
Prabhjyot Singh
Greenhorn

Joined: Dec 28, 2000
Posts: 22
Avi and Shailesh,
1.Every class, without exception, should have all member variables private.But even private instance members variables of parent class ARE inherited by child classes, although you can not access those variable with child object's handle directly but any method/member function can use them.So inheritence does break OO concept of abstraction of super types.
2.Does smalltalk support M-inheritance
Ta,
prabh
dharini thyagaraj
Greenhorn

Joined: Jan 24, 2001
Posts: 13
Dear prab,
See, abstraction is description of an entity in terms of its interfaces without exposing implementation details from the perspective of a viewer. inheritance in no way hampers abstraction. probably you meant to say data hiding /encapsulation.
warm regards,
dharini
Prabhjyot Singh
Greenhorn

Joined: Dec 28, 2000
Posts: 22
dharini,
yes ur right.i meant encapsulation not abstraction.But even if we consider OO concept of abstract, java's concept of class goes against this also since a client object can send messages to a CLASS also, which should not be there.I mean class should only have implementation but not interface.Clients should be able to talk to only "java interfaces" but not "java classes".
cheers
Prabhjyot Singh
Greenhorn

Joined: Dec 28, 2000
Posts: 22
dharini,
yes ur right.i meant encapsulation not abstraction.But even if we consider OO concept of abstract, java's concept of class goes against this also since a client object can send messages to a CLASS also, which should not be there.I mean class should only have implementation but not interface.Clients should be able to talk to only "java interfaces" but not "java classes".
cheers
Laojar Chuger
Ranch Hand

Joined: Dec 20, 2000
Posts: 111
I guess the criterion should be whether if it supports object oriented programming paradigm. In the case of Java, it does. Pure or impure is not important is not important as long as it is a better way of programming. Of course, Java is not perfect. For example, it does not have the built in support for design by contract.
Akin Kaldiroglu
Greenhorn

Joined: Oct 10, 2000
Posts: 9
Originally posted by Avi Abrami:
Prabhjyot,
Java is known as a "hybrid" language - not pure OO - because it has - as you mention - "primitive" data types. By the same token, C++ is also known as a "hybrid" language. On the other hand, smalltalk is a "pure" object oriented language since <em>everything</em> is an object and there is no concept of data type. However, smalltalk also has inheritance. As far as I know, inheritance is one of the things that makes an object-oriented language "object-oriented", and smalltalk - being the first OO language - in defining inheritance, gives me the impression that inheritance does not "go against OO".

Hope this has helped you,
Avi.


I don't think we can call Java "hybrid language". Being OO is a matter of paradigm, not type. OO languages try to picture the reality as it is, i.e. in terms of entities, their attributes and their interaction between themselves. Having primitive types doesn't make a language "hybrid". If Java hybrid, what would you call C++? I don't mean that issue of types don't matter. Think about ML. It is totally dynamically typed, or JavaScript, which is typless. But they are no way object-oriented. Having a type system or being strongly-typed have some other implications, pros and cons of course, but I don't think we can call a language "hybrid" just by looking at the types system it provides. A language may have a strongly-typed system and support OO paradigm through a type hierarchy such as the one in Java.
Akin Kaldiroglu
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I do not believe that inheritance goes against OO... one of the first ways OO is usually explained is with the "is a" and the "has a" relationships, used to determine if you should extend a class or simply contain it as an element of your current class. Well... If a parent-child relationship is an "is a" relationship and a child class should not be able to access members of the parent class... then the "is a" relationship is broken... If a child class could not access the parent classes variables in this way, the parent class should not be able to access it's own variables either! Also, a private variable cannot be accessed directly... even from a child class! That is what the private keyword is for!
Also, even though Java is technically not a completely OO language, I believe it should still be called OO since it lies closer to the apogee of OO-ness than most languages... and since no-one stops M$ from calling VC++ and VB OO (both of which I believe are far less OO than Java) Java should still be able to be called an OO language.
Anyway, Just my $0.02,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Java Object oriented language?
 
Similar Threads
JAVA is a pure OO language?
Is JAVA is fully Obj Oreinted?
Pure OO
about java oops
quick class question