Jeanne Boyarsky wrote:
Akashh Kumarr wrote:I tried it without try-catch and it compiles successfully but has a Runtime error, which means it works like Runtime Exception?
No. It works like a checked exception because it is one. Some IDEs are "helpful" and run code that doesn't quite compile. But you should have a compiler error if you aren't catching the exception or declaring it to be thrown. Can you post your example code here?
Paul Anilprem wrote:This question comes from our question bank ( QID enthuware.ocajp.i.v7.2.907 ) and there is a detailed explanation with it:
If a subclass class constructor doesn't explicitly call the super class constructor, the compiler automatically inserts super(); as the first statement of the subclass constructor.
Since the constructor of Bird is private, the subclass cannot access it and therefore, it needs to be made public. protected or default access is also valid.
Please do let us know which part is not clear so that we can improve it. You can also click on "Discuss" button at the bottom of question display screen and post a follow up question directly to us.