1Class X
2{
3 public void methodX()
4 {
5 System.out.println("Class X method");
6 }
7}
8Class Y extends X
9{
10public void methodY()
11{
12System.out.println("class Y method");
13}
14}
15Class Z extends Y
16{
17 public void methodZ()
18 {
19 System.out.println("class Z method");
20 }
21 public static void main(String args[])
22 {
23 Z obj = new Z();
24 obj.methodX(); //calling grand parent class method
25 obj.methodY(); //calling parent class method
26 obj.methodZ(); //calling local method
27 }
28}