• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is Java Object oriented language?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic