Hi all ,
For a program given below ...
public class Superclass {
public static void main(
String[] args) {
System.out.println(new Subclass().methodA());
}
Superclass() {
System.out.println("SuperClass Constructor Executed");
}
private int methodB() {
System.out.println("methodB in Superclass");
return 9;
}
int methodA() {
System.out.println("methodA in Superclass");
return methodB();
}
}
class Subclass extends Superclass {
Subclass() {
System.out.println("SubClass Constructor Executed");
}
protected int methodB() {
System.out.println("methodB in Subclass");
return 1;
}
}
The output for the above says that method B of base class will be called .
Just wanted the clarification for the same .
Thanks in advance ,
Shallu