Java Code Snippet-1
package techyield;
public class GrandParent {
public void method1(int a){
System.out.println("In GrandParent class and in method1
and with one int argument and value is "+a);
}
}
package techyield;
public class Parent extends GrandParent{
public void method1(int a){
System.out.println("In Parent class and in method1 and
with one int argument and value is "+a);
}
}
package techyield;
public class Child extends Parent{
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Main method");
Child child=new Child();
child.method1(2);
}
public void method1(int a){
System.out.println("In child class and in method1 and
with one int argument and value is "+a);
}
}
What is the Output On the Console ?
Select an answer
Please comment below if you have any doubts.