This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance" Watch "Inheritance" New topic
Author

Inheritance

Aashutosh Yadav
Greenhorn

Joined: Mar 01, 2013
Posts: 1

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

Joined: Mar 17, 2011
Posts: 8661
    
  23

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

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 225

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.


OCPJP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance
 
It's not a secret anymore!