Java - Interview Questions and Answers on Constructor Chaining

Q1.  What are the common uses of "this" keyword in java ?

Ans. "this" keyword is a reference to the current object and can be used for following -

1. Passing itself to another method.
2. Referring to the instance variable when local variable has the same name.
3. Calling another constructor in constructor chaining.

Q2.  Can we call constructor explicitly ?

Ans. Yes.

Q3.  What is constructor chaining and how is it achieved in Java?

Ans. A child object constructor always first needs to construct its parent. In Java it is done via an implicit call to the no-args constructor as the first statement


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus