Question: 1 6 - The following class declarations are given. What is the output of the following code segment. Student s 1 = new GradStudent (

16- The following class declarations are given. What is the output of the following code segment.
Student s1= new GradStudent(); s1.getInfo();
public class student {
public String getFood(){
return "Pizza";
}
public string getinfo(){
return this.getFood();
}
}
public class Gradstudent extends Student {
public string getFood(){
return "Taco";
}
}
a) Won't compile since you use this.getFood()
b) Won't compile since you are creating a GradStudent, not a Student
c) Taco
d) Pizza
e) Won't compile since GradStudent doesn't have a getInfo method
Leave blank
 16- The following class declarations are given. What is the output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!