Question: Java-programming use simple jgrasp code please.... Create three classes: superclass Person, sub class Child, and a TestClass The superclass Person will have one instance variable:
Java-programming use simple jgrasp code please....
Create three classes: superclass Person, sub class Child, and a TestClass
The superclass Person will have one instance variable: int age
It will also have a constructor that requires the int age argument.
There will be two methods: getAge() and setAge()
There will also need to be a toString() method that returns the value of the age variable.
There is another method required: speak()
The speak() method has a String as an argument. The speak() method prints out the speak argument.
The sub classChild extends the Person class.
It has one instance variable- schoolName of type String
The Child class has a constructor that requires two arguments (int age, String schoolName).
Pass the age argument to the Person superclass. Pass the schoolName argument to the Child class instance variable.
There are two methods:GetschoolName() and setSchoolName(). They return the schoolName variable and set the schoolName variable respectively.
In addition there is a toString() method that returns age and schoolName.
Create a Test class with a main method.
Create a Child class passing in the age and schoolName.
Call the speak method of the child argument, passing in a phrase to speak.
Call the toString() method of the child class and print out the results.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
