hi all,
Hope we all are enjoying
java,
Question 1
Well my quest is, the this() call invokest the constructor with the corresponding parameter list.
Please ellaborate the idea. I think the decision is made at the time when we are instantiating the constructor.
Question 2
Given the Code below is in file SubClass.java, What is the result of compiling and running SubClass.java
class BaseClass{
public BaseClass(
String s){
System.out.println(s);
}
public BaseClass(int i){
this("I am BaseClass Integer");
}
}
public class SubClass extends BaseClass{
public SubClass(int i){
System.out.println("I am SubClass Integer");
}
public static void main(String[] arg){
SubClass sc = new SubClass();
}
}
A.Does't Compile
B.Compiles but generates runtime error
C.Compiles & runs successfully and the output is :
I am SubClass Integer
I am BaseClass Integer
D.Compiles & runs successfully and the output is :
I am BaseClass Integer
I am SubClass Integer
Answer is not available please suggest the most appropriate answer.
Thanx in advance.