Question
Add a new constructor to Person. This constructor takes first name, last name and age as parameters. Reuse the code in the existing constructor of
Add a new constructor to Person. This constructor takes first name, last name and age as parameters. Reuse the code in the existing constructor of Person. All classes inherit (at least) from class "Object", which has a method toString(). This method is invoked automatically when casting an object to a String. For example, when you write "System.out.println(o)", method o.toString() is implicitly invoked. Override the toString() method in Person, so that it returns first name and last name. Create a class Faculty which inherits from Person. This class carries a new private variable, named title (type String) with default value "Mr.". Redefine method toString() of Faculty so that it returns the title in front of the faculty's name. Define a new class Student, which includes the student's GPA as a private variable. Add a constructor that takes the student's name (first/last) and gpa as parameters. Think carefully about how constructors should be handled in this class. Add a method to set the student's GPA. Why is this method necessary? Complete class Organization, adding an array of five elements that holds two faculties and three students. Populate the array with sample data (no need to read it from the user) and then print the data.
Program in JAVA
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started