when it comes to primitives jvm allocates 4 bytes for integers, 2 byte for characters, and for boolean it's JVM dependent. When it comes To objects the memory allocated depends upon the number and type of the instance variables.
Now my question is i have a class which does not contain any instance variables and methods, So if i create an object of such a class how much memory gets allocated for that object?
class A{
}
class B{
public static void main(
String args[]){
A x=new A();
}
}
How much is the memory allocated for object of class A which is being reffered by variable x?