Welcome Guest | Sign in | Register
Inheritance - Discussion Page For Q.2849 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Inheritance > Questions and Answers

Q: class A{
A(){
This(10);
System.out.println(1);
}
A(int i){
This();
System.out.println(2); }
}
Class Manager{
Public static void main(String args[]){
System.out.println(“done”);
} }
A. 1,2 B. 2,1
C. compile time error D. run time error

Answer and Explanation

Answer:compile time error

Explanation:
here in class A there are two constructor one with no parameter, other with one parameter, in each constructor we are using this() keyword , from no parameter constructor we are calling parameter constructor using this() keyword, and from parameter constructor we are calling no parameter constructor using this() keyword, so it will become cyclic calling so it will throw an compile time error

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.