class Profession{
void check(){
System.out.println("profession class");
}
}
class Employee extends Profession{
void check(){
System.out.println("Employee class");
}
}
class Teacher extends Employee{
void check(){
System.out.println("Teacher class");
}
public static void main(String args[]){
Profession obj1 ,obj2, obj3;
obj1=new Profession();
obj2=new Employee();
obj3=new Teacher();
obj1.check();
obj2.check();
obj3.check();
}
}
profession class
Employee class
Teacher class
Press any key to continue . . .
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.