This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes What Inheritance Actually Do Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "What Inheritance Actually Do" Watch "What Inheritance Actually Do" New topic
Author

What Inheritance Actually Do

Satyendrakumar panasa
Greenhorn

Joined: Nov 21, 2005
Posts: 1
We Have two Classes A and B
a is a method in A
b is a method in B
When we inherit Class A into B
After that we create a object referance to Class B
Then what happend in heap area.
Whether two objects are created or only object is created for B
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please post general Java questions in our Java In General forums.
Moving to Java In General (Beginner).


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12953
    
    3

Only one object is created and it is of type B, but that object contains all the members of class B, and also the members that it inherited from class A.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Srinivas Kumar
Ranch Hand

Joined: Jul 14, 2005
Posts: 52
Not all members will be inherited ;-).
Only public and protected members will be inherited.if the subclass belongs to the same package as that of super class, then default members in the super class will also be inherited.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What Inheritance Actually Do
 
Similar Threads
Why it prints like this here?
problem of tester?
String declaration
Circular Reference in Java
Strings