• Post Reply Bookmark Topic Watch Topic
  • New Topic

What Inheritance Actually Do  RSS feed

 
Satyendrakumar panasa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post general Java questions in our Java In General forums.
Moving to Java In General (Beginner).
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srinivas Kumar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!