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

Difference between String and StringBuffer.

3 Answers   GE, IBM,


In Java why we write public static void main(String args[]) why not main()?

46 Answers   Aptech, GE Healthcare, Infosys, Microsoft, New Horizon, Practical Viva Questions, TCS, Wipro,


What Is Composition?

0 Answers   IBS,


What is the relationship between a method?s throws clause and the exceptions that can be thrown during the method?s execution?

2 Answers  


What is the method used to get the absolute value of a number?

2 Answers  






what is difference between length and length()?

8 Answers  


what is the difference between HashMap And HashTable?

5 Answers   Hexaware,


Can we serialize static variables in java?

0 Answers  


How do you achieve polymorphism in java?

0 Answers  


How static variable work in java?

0 Answers  


What is singleton service?

0 Answers  


Explain the features of java?

0 Answers  


Categories