Answer:
public class Leo{
public String method1(){
return "Jack 1 Leo 1";
}
public String method2(){
return "Don 2 Jack 2";
}
public String method3(){
return "Jack 3 Leo 3 Don 2";
}
public String toString(){
return "Jack 3 Leo 1"
}
}
public class Jack extends Leo{
}
Step-by-step explanation:
Leo is the parent class and jack inherits all of its attributes from Leo
So when you call the following code in the main method:
Jack j = new Jack();
System.out.println(j.method1);
it should print Jack 1 Leo 1
This is because the program first checks if method 1 exists in the Jack class
Because it doesn't exist it then goes to the parent class which is Leo.
And in the Leo class method1 displays "Jack 1 Leo 1 "
So it prints that