File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is parent and child Class?

 
Rena Tjioe
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and Good Morning to all,

May I know what is the difference between the parent and the child classes.

I found out that the parent class is the base class and that the child class is derived from it and there is also the ancestor class and decendent, but I do not understand what it all means.

Is there any other way to explain this to make it easier to understand.

Is this concept the same for the Parent and Child Component?

Thank you

Rena Tjioe
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rena Tjioe:

I found out that the parent class is the base class and that the child class is derived from it and there is also the ancestor class and decendent, but I do not understand what it all means.



Reusablity purpose

1.Inheritence is designed to support reusability.
2.To support the polymorphism
3.subclass can access superclass propeties vice versa not pssible.
[ it is like you can access your father properties,but your father can not access yours properties]

Hope this will help you
 
Rakesh Chaudhary
Ranch Hand
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Let me try,

A Child inherits some looks and behaviors from his parents.


A natural rule as I would say!

Similarly a child class inherits some behaviors from a parent class.But these behaviors are in the form of methods and some data.

Inheritance , Polymorphism , Encapsulation and Abstraction are the further principles of OOP's for Mapping the State(Data) and Behavior(method).
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by seetharaman venkatasamy
3.subclass can access superclass propeties vice versa not pssible.
[ it is like you can access your father properties,but your father can not access yours properties]


Did you mean that using super class reference you cannot access child class specific members
Nothing stops from accessing the inherited members.


Hope this helps
 
Campbell Ritchie
Sheriff
Pie
Posts: 47292
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you will all complain I am being pedantic, but they are not called "child" and "parent." They are called "subclass" and "superclass."

"Parent" and "child" are used in Java for GUI components; if you have something inside something else, the "something" is called a "child" and the "something else" is called its "parent" and something outside that can be called an "ancestor."

Other languages might have different names, but that (as far as I can remember) is what they are called in Java.
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but they are not called "child" and "parent." They are called "subclass" and "superclass."

I agree Campbell, even from the OOP perspective, subclass and superclass make more sense than parent and child.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47292
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Ghorpade:

I agree Campbell, even from the OOP perspective, subclass and superclass make more sense than parent and child.
Maybe what they are called in C#, namely base class and derived class, is better, but "superclass" and "subclass" is what they are called in Java.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell
 
Campbell Ritchie
Sheriff
Pie
Posts: 47292
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic