Question: In a file named Student.java, write a class called Student with first name, last name, gender, and age attributes. Give the class a three-argument and
In a file named Student.java, write a class called Student with first name, last name, gender, and age attributes.
-
Give the class a three-argument and a four-argument constructor. The three- argument constructor should take the Students first name, gender and age as parameters and set the last name to be an empty String.
-
The four-argument constructor should take the Students first name, last name, gender and age as parameters.
-
Give the class a method that returns the age group of a student:
-
Child: if a student is younger than 12
-
Teenager: if a student is aged between 13 and 19
-
Young Adult: if a student is aged between 20 and 25
-
Adult: if a student is older than 25
-
-
Give the class a method called display which displays the Students attributes along with the age group that the Student is in.
-
In a separate file named Lab1.java create one Student object for each age group and invoke the display method for each object. Ensure that both constructors are used at least once.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
