object creation in java behind scenes (java object instantiation) -


i understand there 3 parts object creation:

  1. declaration
  2. instantiation
  3. initialization

classa{} classb extends classa{} classa obj = new classb(1,1); 

instantiation

it has create object using new operator , object must have fields related classb (initialized default values step give call default constructor?) instantiation mean step initialization using java's default constructor?

initialization

this object passed down hierarchy giving calls various constructor in way initialized (which comes under initialization) , final obj created 'classb(1,1)` constructor whith required initializations

but how object mentioned in instantiation step being created available fields?

please point out if said wrong

if class has no constructor default constructor implicitly defined. constructors have method name <init> in stacktrace.

a constructor call following:

  1. the object created, fields nulled: 0, 0.0, null, ...
  2. the super constructor called, possibly implicit if not present in code.
  3. all initialized fields (a = ...;) initialized doing assignments.
  4. the rest of constructor executed.

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -