• 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

oops concept

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to java.
I have question like what is enapsulation,inheritence,polymorphism.
could any body explain me with a good example and defination.

thanks and regards.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Have a look @
http://www.javaranch.com/campfire.jsp
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Encapsulation is the equivalent of data hiding. You protect your instance variables (your data), and control access through setter and getter methods. You also mark instance variables as being private. In Java, we don't expose our privates.

Inheritance is a mechanism used to represent an is-a relationship between objects. So, a Square is-a special Rectangle, and a Rectangle is-a special type of Shape, and a Shape is-a type of Object.

Polymorphism says any time you need an object, and instance of that object, or instance of a more specific type will do. So, if I need a Shape, a square will do. If I need a Rectangle, a Rectangle or a Square will do. Note that polymorphism is unidirectional, so if you need a Shape, a Rectangle will do, but if you need a Square, a rectangle will not suffice.

Those are very brief answers to a very broad set of questions.

Cheers!

-Cameron McKenzie
 
reply
    Bookmark Topic Watch Topic
  • New Topic