File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance

 
Aashutosh Yadav
Greenhorn
Posts: 1
Android C++ Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we inherit a class then does it increase the size of the child's object in memory ?
e.g. let a class has two instance variable and two methods,on creating its object it cover some space in memory.
Now if this class inherits a class having two public variables and tow public methods, now does this increase the space covered by child class's object in memory ?
please explain it in context of normal class,abstract class and interface............!!!
 
Winston Gutkowski
Bartender
Pie
Posts: 9461
49
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aashutosh Yadav wrote:if we inherit a class then does it increase the size of the child's object in memory ?

Simple answer: probably.

Proper answer: Without a lot of testing you simply don't know, because AFAIK it is not specified in the JVM spec.

It's also something you really don't need to concern yourself with. Java memory is the business of the JVM, not you.

Winston
 
Ishan Pandya
Ranch Hand
Posts: 225
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as i think some pointers from the subclass to the instances of superclass are created.
Actually i dont think it is specified anywhere as Mr.Winston said.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic