What will happen when you attempt to compile and run the following class?
class Base{
Base(int i){
System.out.println("Base");
}
}
class Severn extends Base{
public static void main(
String argv[]){
Severn s = new Severn();
}
void Severn(){
System.out.println("Severn");
}
}
1) Compilation and output of the string "Severn" at runtime
2) Compile time error
3) Compilation and no output at runtime
4) Compilation and output of the string "Base"
Answer is 2.
Answer explanation given is : An error occurs when the class Severn attempts to call the zero parameter constructor in the class Base
Can any one please explain , where in the program the class Severn attempts to call the zero parameter constructor in the class Base . And also explain why is that answer is 2 , why is not 3.
Thanks,
Sdev.