Here is the question:
** Consider the following class definition:**
public class Student {
public String getFood() {
return "Pizza";
}
public String getInfo() {
return "Studying";
}
}
public class GradStudent extends Student {
public String getFood() {
return "Taco";
}
public String getInfo() {
super.getInfo();
return "Eating";
}
}
What is printed when the following code is executed?
Student s = new GradStudent();
System.out.println(s.getInfo());
(A) Pizza
(B) Taco
(C) Studying
(D) Eating
(E) Studying
Eating
When I followed the code, I saw that super.getInfo() returns "Studying" and then the next line (return "Eating") will return Eating. I'm confused why the answer is only eating. Doesn't "studying" also get returned? And shouldn't it be the first thing returned? This is very confusing and I'm sorry if its a dumb question