Question: Consider the following class: class Person { String name; int age; Person (String name, int age) { this.name = name; this.age = age; }

Consider the following class: class Person { String name; int age; Person

 

Consider the following class: class Person { String name; int age; Person (String name, int age) { this.name = name; this.age = age; } } a) Write a java program with two classes "Teacher" and "Student" that inherit the above class "Person". Each class has three components: extra variable, constructor, and a method to print the student or the teacher info. The output may look like the following (Hint: you may need to use "super" reserved keyword in your implementation): My name is: Ahmed My age is: 35 My salary is: 8000 My name is: Khalid My age is: 12 My grade is: 6 b) Draw a UML diagram that shows super and subclasses with the relationship between them.

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 Programming Questions!