What occurs when object is created in Java?

后端 未结 5 403
情深已故
情深已故 2020-12-08 18:12

My teacher gave me a question:

\"What occurs when objects are created in Java\".

To the best of my knowledge, memory allocation

5条回答
  •  一生所求
    2020-12-08 18:29

    On top of what other people have said, if this is the first use of the object then its Class must be initialised -as described in the JLS (the section before the one on new instance creation!).

    This basically involves loading into memory the necessary information about the class i.e. creating a Klass object for the static variables and method table to live. This may also involve loading super classes and interfaces. This is all carried out by the ClassLoader.

提交回复
热议问题