Question: Question 1. (8 pts) Consider the following code: class Q1 { public static void main(String[] args) { Grad g = new Grad (Alice); Undergrad u

 Question 1. (8 pts) Consider the following code: class Q1 {

Question 1. (8 pts) Consider the following code: class Q1 { public static void main(String[] args) { Grad g = new Grad ("Alice"); Undergrad u = new Undergrad ("Bob"); Student [] reg = { g, u }; for (Student stud : reg) { System.out.println(stud.getInfo()); } System.out.println(g.getInfo(false)); } } abstract class Student { public String getInfo() { return "N/A"; } } class Undergrad extends Student { public Undergrad (String aName) { this.name = aName; } public String getInfo() { return this.name + " is an undergraduate student"; } private String name; } class Grad extends Student { public Grad (String aName) { this.name = aName; } public String getInfo() { return this.name + " is a graduate student"; } public String getInfo(boolean detailed) { if (detailed) return this.getInfo(); else return this.name; } private String name; } Which features does this code demonstrate? Mark all that apply. You may select many: Interfaces Dynamic binding Subtyping Multiple class inheritance Overridden methods Dynamic typing Overloading None of the above

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!