Quick revision
The short answer
The first new Child() prints Ps Cs Pi Pc Ci Cc. Class initialisation comes first, superclass before subclass, so Parent's static block (Ps) runs, then Child's (Cs). Then the instance is created: Child() calls super(), Parent's instance initialisers run (Pi) followed by Parent's constructor body (Pc), and then Child's instance initialisers (Ci) and the rest of Child's constructor (Cc). A second new Child() prints only Pi Pc Ci Cc, because each class is initialised once. Within a class, field initialisers and instance blocks run in the order they are written.
What to remember
In this answer, we followed new Child() through two phases. Class initialisation runs once, superclass first, printing Ps then Cs. Object creation runs every time: Child() calls super(), Parent's instance block and constructor body print Pi and Pc, and then Child's instance block and constructor body print Ci and Cc, giving Ps Cs Pi Pc Ci Cc the first time and Pi Pc Ci Cc afterwards. Initialisers of the same kind run in textual order, and since the parent constructor runs before the subclass's initialisers, overridable methods called from constructors see default field values.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The first new Child() prints Ps Cs Pi Pc Ci Cc. Class initialisation comes first, superclass before subclass, so Parent's static block (Ps) runs, then Child's (Cs). Then the instance is created: Child() calls super(), Parent's instance initialisers run (Pi) followed by Parent's constructor body (Pc), and then Child's instance initialisers (Ci) and the rest of Child's constructor (Cc). A second new Child() prints only Pi Pc Ci Cc, because each class is initialised once. Within a class, field initialisers and instance blocks run in the order they are written.
Why this question is asked
Initialisation order sounds like trivia until it causes a bug: a static field that is still null when a static block reads it, or a subclass field that is zero when the superclass constructor calls an overridden method. Interviewers ask this classic puzzle to see whether we can reason about the two separate phases, class initialisation and object creation, and about where the hidden super() call fits. In this answer, we will recap the kinds of initialisers, follow the first new Child() phase by phase, see what changes on the second call, and look at textual order and a common trap that follows from all this.
1A Quick Recap: Static and Instance Initialisers
A static initialiser, written static { ... }, belongs to the class. It runs once, when the JVM initialises the class, together with the initialisers of static fields, such as static int max = 10. An instance initialiser, written as a plain block { ... } in the class body, belongs to each object. It runs every time an object is created, together with the initialisers of instance fields, such as int count = 1, and before the rest of the constructor body.
Two phases follow from this. Before the first object of a class can be created, the class must be initialised, which runs its static parts; and a class's superclass is always initialised before the class itself. Then, for each new object, the instance parts and constructors run.
2Following the First new Child()
Here is the code from the question, written out with a helper p that prints its argument followed by a space.
- Initialise Parentstatic block prints Ps
- Initialise Childstatic block prints Cs
- Child() calls super()control moves to
Parent() - Parent(): Object(), then instance blockprints Pi
- Rest of Parent()prints Pc
- Child(): instance block after super returnsprints Ci
- Rest of Child()prints Cc
7 steps in order. Play them, or step through them one at a time.
Only the first two steps are skipped on a later new Child().
The first new Child() needs Child to be initialised. Before initialising Child, the JVM initialises its superclass Parent, so Parent's static block prints Ps. Then Child's static block prints Cs. Class initialisation is now complete for both.
Next comes object creation. Child() starts with an implicit super(), so Parent's constructor runs first. Inside a constructor, the instance initialisers of that class run right after the super call returns; Parent's super call goes to Object, then Parent's instance block prints Pi, and then the rest of Parent() prints Pc. Control returns to Child(): now Child's instance block prints Ci, and finally the rest of Child() prints Cc.
3Why the Second new Child() Is Shorter
A class is initialised exactly once per class loader. After the first new Child(), both Parent and Child are marked as initialised, so the JVM skips straight to object creation. The second call prints only Pi Pc Ci Cc, the instance part, which runs for every object.
This is also why static blocks are the place for one-time setup, such as building a lookup table, and instance blocks or constructors are the place for per-object setup.
4Textual Order Within a Class
Within one class, field initialisers and initialiser blocks of the same kind run in the order they appear in the source. The compiler effectively copies them, in order, into each constructor right after the super call.
The same holds for static fields and static blocks. A static block that reads a static field declared below it sees the field's default value, because that field's initialiser has not run yet. Moving declarations around can therefore change behaviour, which is a good reason to keep initialisation simple and declared before use.
5The Trap: Overridable Methods in Constructors
The order also explains a classic bug. Because Parent's constructor runs before Child's instance initialisers, a method that Child overrides and Parent calls from its constructor sees Child's fields at their default values.
The fix is to avoid calling overridable methods from constructors. If the parent needs a value from the subclass, it can take it as a constructor parameter, or the method can be made private or final.
6Follow-up questions
What if the code only declared a Child variable without creating an object?
Declaring Child c; or c = null; does not initialise anything. A class is initialised on its first active use, such as creating an instance or calling a static method, so nothing would be printed until then.
Where do constructor parameters fit relative to instance blocks?
Instance blocks and field initialisers run after the super call and before the rest of the constructor body, so they cannot see values that the constructor body assigns later. That is one reason most code puts per-object setup in the constructor rather than in instance blocks.
Does Java 25's flexible constructor body change this order?
Statements in the prologue, before an explicit super(...), run before the superclass constructor, but they cannot use the instance, and this class has no explicit super call. The order Ps Cs Pi Pc Ci Cc is unchanged.
7Conclusion
In this answer, we followed new Child() through two phases. Class initialisation runs once, superclass first, printing Ps then Cs. Object creation runs every time: Child() calls super(), Parent's instance block and constructor body print Pi and Pc, and then Child's instance block and constructor body print Ci and Cc, giving Ps Cs Pi Pc Ci Cc the first time and Pi Pc Ci Cc afterwards. Initialisers of the same kind run in textual order, and since the parent constructor runs before the subclass's initialisers, overridable methods called from constructors see default field values.
Open with
The first new Child() prints Ps Cs Pi Pc Ci Cc. There are two phases. First, class initialisation: before an object of Child can exist, the JVM initialises Child, and before that it initialises the superclass Parent, so Parent's static block prints Ps and then Child's prints Cs.
Then, if they want more
That happens once per class. Second, object creation. Child's constructor starts with an implicit super(), so Parent's constructor runs first. Inside each constructor, after the super call returns, that class's field initialisers and instance blocks run in textual order, and then the rest of the constructor body.
So Parent prints Pi from its instance block and then Pc from its constructor body. Back in Child, the instance block prints Ci and the constructor body prints Cc. A second new Child() skips class initialisation, because both classes are already initialised, so it prints only Pi Pc Ci Cc.
I'd also mention the practical consequence: because the parent constructor runs before the child's field initialisers, if the parent constructor calls a method the child overrides, the override sees the child's fields still at null or zero, so I avoid calling overridable methods from constructors.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "In what order do these run when new Child() is called for the first time?": https://scrivio-interview-library.netlify.app/java/classes-and-objects/5edc31e273/