Are constructors inherited? Can a subclass call the parent's class constructor? When?
You cannot inherit a constructor. That is, you cannot create a instance of a subclass using a constructor of one of it's superclasses. One of the main reasons is because you probably don't want to overide the superclasses constructor, which would be possible if they were inherited. By giving the developer the ability to override a superclasses constructor you would erode the encapsulation abilities of the language.
-
Interview Candidate
- Aug 28th, 2004
- 2
- 13744
Showing Answers 1 - 2 of 2 Answers
Are constructors inherited? Can a subclass call the parent's class constructor? When?