Skip to main content

(Not So) Stupid Questions 13: The Construction of Constructors

September 26, 2006

(Not So) Stupid Questions

Timing of a constructor's call to its superclass' constructor

Editor's note: Sometimes the most interesting discussions begin when someone says, "This may be a stupid question, but ...." If the person asking the question has taken the time to think about the problem before asking, the question is often not stupid at all. The uncertainty points out an ambiguity in the specs, holes in the docs, or a search for how more experienced programmers might address a particular problem. From time to time, we will print one of the "(Not So) Stupid Questions" we receive and invite our readers to answer the question in the feedback section.

Remember that new people are joining the Java community all the time and may be looking for help from those with more experience. Also, those who began with Java as their first language can benefit from those coming to the community with experience in other languages. As always, answer the questions with kindness. You are also welcome to submit your questions to

This may be a stupid question, but ... "Why do constructors have to start with a call to super()?"

First thoughts:

This is more of a "why" than a "how" question. Any call to the constructor of a superclass must come on the first line of the constructor of the subclass. I frequently find that it would be handy to be able to prepare some values or objects to initialize a superclass with and find this a bit of a frustrating feature of Java. Does anyone know why this feature exists?

I am totally stumped for a good reason why this might be, but a very superficial guess might be that internally in the compiler, this makes some sort of simplification or optimization. Unfortunately, what I know about the internal workings of the JVM and Java compiler would comfortably fit on the back of a stamp, so that's about as far as I can go.

Still, it can be really inconvenient to not have control over when the superclass constructor gets called, so someone please tell me:

Why can I only call a superclass' constructor as the first statement of the subclass' constructor?

Related Topics >> Programming   |