What is the output of the following program? (Assume all the…
What is the output of the following program? (Assume all the classes are in separate files.) public class Person { public Person() { System.out.println(“Person”); }}public class Student extends Person { public Student() { System.out.println(“Student”); }}public class CollegeStudent extends Student { public CollegeStudent() { System.out.println(“CollegeStudent”); } public CollegeStudent(String name) { System.out.println(“CollegeStudent with name setup”); }}public class Main { public static void main(String[] args) { CollegeStudent s = new CollegeStudent(“Sally”); }}
Read DetailsPredict the output of the numbered lines in the main method….
Predict the output of the numbered lines in the main method. Write the proper output for each line.If a line would cause an error, assume that the program would continue and write”Error”.Example answer:1. Error2. Student/Normal Person/Computer Science… public class Person { public void printType() { System.out.println(“Normal Person”); }}public class Student extends Person { public void printType() { System.out.println(“Student”); } public void printMajor() { System.out.println(“Computer Science”); }}public class Main { public static void main(String[] args) { Person a = new Person(); Person b = new Student(); Object c = new Student(); c.printType() //[output1] b.printType(); //[output2] b.printMajor(); //[output3] a.printType(); //[output4] }}
Read Details