This discussion is archived
4 Replies Latest reply: Mar 17, 2009 11:59 PM by 843785 RSS

sub class will allocate seperate memory for super class  instance variable?

843785 Newbie
Currently Being Moderated
class A
{
int i, j;
void showij()
{
System.out.println("i and j: " + i + " " + j);
}
}
class B extends A
{
int k;

void showij()
{
System.out.println("i and j: " + i + " " + j);
}
}

what is size of class B will it be just 4 byte for k or 12 bytes for i, j and k ?
will be a seperate copy of i and j in B or address is same ?
thank u