| 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
|
|
|
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.
|
 |
 |
|
|
subject: What Inheritance Actually Do
|
|
|