XII. In this step, you are going to display the class hierarchy through a progra
ID: 3709817 • Letter: X
Question
XII. In this step, you are going to display the class hierarchy through a programming API- getSuperclass() method of a Class class - in your program. 1. Modify Main.java with the code below. // Display the class hierarchy of the InternationalStudent // class through getSuperclass() method of Class class. Class class1 internationalStudent1.getClass System.out.printin("Displaying class hierarchy of InternationalStudent Class..."); while (class1.getSuperclass) !null) String child class1.getName); String parent = class1.getSuperclass().getName(); System.out.printin(" "+child +"class is a child class of" +parent); classi - class1.getSuperclass); XIII. Compile and execute your program, what does the output show? Is the output correct? XIV.List two advantages of using inheritance.Explanation / Answer
Please provide the Main.java class which you want to edited as per the question XII requirement.
Here are the answer of the last question.
Advantages of the Inheritance:
Minimize the duplicate code:
Inheritance help to minimize to minimize the duplicate code by using the code of the base class
Data hiding:
Base class can keep some of its data private so that no other subclass can alter it's data.
Overriding:
Some of the methods in the base can be override in the derived class a per requirement in the derived class
Reusability
The public methods of the base class can be used by the derived class without rewriting them.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.