Why can't compiler insert implicit constructor here (with throws clause), because it has info about parent class.
Because constructors are not inherited.
And as class DogFamily contains nothing but a constructor, there's not much info in it. If you extend DogFamily, the subclass must have a constructor with the same parameters (no parameters here) and it must throw the same exception. Or a superclass of this exception.
all events occur in real time
Joined: Feb 28, 2007
Thanks Burkhard & Swarna!
Burkhard, I liked the very first line: Because constructors are not inherited!
The above is how the compiler default constructor would look like and it gives the following compiler error: Exception 'java.io.IOException' thrown by the field initializer or the constructor is not caught and does not appear in throws clause of the constructor
Now I thought what if I try to catch it like following...
The compiler is still not happy becuase the word super() has to be the first line of the constructor and seems like word "try" tried to overthrow "super()" from its supermost position
So the only way it would let atleast the two classes compile is
Now again I mistakenly thought that with the above code segment whenever I try to instantiate BullDog It will throw a exception at runtime too. But it doesnt... It just needs the declaration of the error or catching ofcourse just for compiler