Is this the way Constructor in Java allocates memory?

前端 未结 5 1756
遥遥无期
遥遥无期 2021-01-07 04:45

Default constructor is automatically called after an object is created.

But in Java when we allocate memory using new operator i.e. classname obj = new classna

5条回答
  •  再見小時候
    2021-01-07 05:06

    "...then how default constructor actually do so as the class has not come into physical existence. "

    The class is already in memory, the new operator allocates memory space to hold the instance variables and parents instance variables specific to the new instance. But the class had come into physical existence before.

提交回复
热议问题