What is the output of the following code? public class Test { public static void main(String[] args) { new Person().printPerson(); new Student().printPerson(); } } class Student extends Person { public String getInfo() { return "Student"; } } class Person { public String getInfo() { return "Person"; } public void printPerson() { System.out.println(getInfo()); } }

What is the output of the following code?
public class Test {
  public static void main(String[] args) {
    new Person().printPerson();
    new Student().printPerson();
  }
}
class Student extends Person {
  public String getInfo() {
    return "Student";
  }
}
class Person {
  public String getInfo() {
    return "Person";
  }
 
  public void printPerson() {
    System.out.println(getInfo());
  }
}



A. Person Person
B. Person Student
C. Stduent Student
D. Student Person

The correct answer is B


Java

Learn More Multiple Choice Question :