← Quiz: Object Initialization Order: all 10 questions
Quiz: Object Initialization Order · Question 2 of 10
When does a class's static block run?
When does a class's static block run?
- A.When the JVM starts, before main
- B.Every time an object is created
- C.Once, the first time the class is used
- D.Only when a static method is called
Answer & explanation
Correct answer: Once, the first time the class is used
Class initialisation happens once, on the first real use of the class.
Can you get the rest right without peeking?
Take the timed Quiz: Object Initialization Order quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →