ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

Constructors in Inheritance

--whenever the subclass obj is created,its appropriate constructor is called first,but not execute.from there an implicit call is made to the superclass default constructor if available.

--now the superclass constructor  execute first and then the subclass constructor.

--in the superclass,if zero arguement constructor is not available,the compiler gives an error.we can rectify the error in two ways...

1.providing the zero arguement constructor in the superclass.

2.calling the superclass parameterised constructor explicitly.

--the first solution is not always fesible.

--whenever the superclass parameterised constructor is required to be called explicitly from within the subclass constructor,we use the "super" keyword.but condition is that,in the subclass constructor,the explicit call should be the first statement.

 

Related Posts Plugin for WordPress, Blogger...
Flag Counter