class A
{
private int i;
}
class B extends A
{
private int i;
}

if I create an object of B class what will be the memory of that object.

Answers were Sorted based on User's Feedback



class A { private int i; } class B extends A { private int i; } if I create an object..

Answer / core java

In general we can't get the size of the object.
we Just cant think about this.Because the object is created
by **JVM**.Not by us.Internally some memory location is
allocated by the JVM.who we are talk about the object size.

but for out satisfication we are saying that some size
that depends on the variables only(primitive data types).

When object of the class B is created ,object of C and
object Of Object class are also created.Those properties
references are available in object of class B.

So we just can not think about the size of the object
really.

Is This Answer Correct ?    14 Yes 0 No

class A { private int i; } class B extends A { private int i; } if I create an object..

Answer / bhavya

12 bytes

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More Core Java Interview Questions

List interface?

2 Answers  


Explain Stream Tokenizer?

4 Answers  


What are field variable and local variable?

3 Answers  


What are the different access modifiers available in java?

0 Answers  


if am have 100 threads(for ex:T1,T2---T100) how we give priority to these threads and how the system excute these threads

2 Answers  






how are methods defined?

0 Answers  


what is difference between throw and throws in exception?

48 Answers   Spenco,


Why can't we make jsp as a controller and action servlet in struts?

8 Answers   TCS, Wipro,


What is the top class of AWT event hierarchy?

5 Answers  


Can an interface extands a class?

5 Answers  


Why are generics used?

0 Answers  


What is a for loop in java?

0 Answers  


Categories