← Quiz: Object Initialization Order: all 10 questions
Quiz: Object Initialization Order · Question 5 of 10
Parent Person has only the constructor Person(String name). What happens with class Student extends Person { Student()…
Parent Person has only the constructor Person(String name). What happens with class Student extends Person { Student() { } }?
- A.Compile error, because the hidden super() has no matching constructor
- B.It compiles and name is null
- C.Runtime NullPointerException
- D.Java creates a no-argument constructor in Person automatically
Answer & explanation
Correct answer: Compile error, because the hidden super() has no matching constructor
Java adds a default constructor only to a class with no constructors at all.
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 →