Directly accessing Grandparent’s member in Java: Predict the output of following Java program. // filename Main.java class Grandparent { public void Print() { System.out.println("Grandparent's Print()"); } } class Parent extends Grandparent { public void Print() { System.out.println("Parent's Print()"); } } class Child extends Parent { public void Print() { super.super.Print(); // Trying to access Grandparent's Print() System.out.println("Child's Print()"); } } public class Main { public static void main(String[] args) { Child c = new Child(); c.Print(); } } Output:
Read full article from Accessing Grandparent’s member in Java | GeeksforGeeks
No comments:
Post a Comment