class Exam {
protected
String difficultyLevel="easy";
public void printDifficulty(){
System.out.println(difficultyLevel);
}
}
class SCJPExam extends Exam {
private String difficultyLevel="killing";
//public void printDifficulty(){
//System.out.println(difficultyLevel);
//}
public static void main(String args[]) {
SCJPExam myExam=new SCJPExam();
myExam.printDifficulty();
}
}
Since the subclass SCJPExam did not override the printDifficulty() method super class's printDifficulty() method is invoked and hence prints easy.
If the comments are removed in the above program it would print:
killing
Thanks