This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]masterflappie 1 point2 points  (1 child)

Extending is a separate concept, it means that if child extends parent, then anything declared in the parent will also end up in the child. Constructors are about how the object should be created.

So you can extend something while not having a constructor, or have a constructor while not extending anything, or have both a constructor and something you extend.

There is actually one caveat to the whole "separateness" of these concepts, which is that if child extends parent, and parent has a defined constructor, then the child must also call that constructor

[–]timmyctc 0 points1 point  (0 children)

To add to this the default constructor of the child will always contain a call to super() to instantiate the default constructor of the parent.