2013年10月1日星期二

Small problems look

In the subclass inherits the parent class after , new sub-class , the parent class will be allocated in the heap memory space?
as follows:
class A {}
class B extends A {
public static void main (String [] args) {
new B ();
}
}
When the program is executed new B () , it will be an object in the heap memory to allocate memory space for the B , my question is :
B Class A parent will be allocated in the heap memory space? Or simply call the parent class constructor it ?
Thank you !
------ Solution ---------------------------------------- ----
because you only new one object, so distribution is an object of memory space, but the space is part of the ( class A properties ) a class can be accessed .
------ Solution ---------------------------------------- ----
will allocate heap memory space. By default constructor subclass object of the parent class constructor will be called first .
------ Solution ---------------------------------------- ----
must be , or how to call the parent class method
------ Solution ------------------------ --------------------
will , new sub-class is first instantiated parent class
------ For reference only ---- -----------------------------------
upstairs basically answers the

没有评论:

发表评论