Problem

In the Self-Test Question described a class Person to represent a person. The class has in...

In the Self-Test Question described a class Person to represent a person. The class has instance variables for a person’s name, which is a string, and an integer age. These variables are name and age, respectively.

a. Write a default constructor for Person that sets name to the string "No name yet" and age to zero.


b. Write a second constructor for Person that sets name to a given string and age to a given age.


c. Write a static method createAdult for Person that returns a special instance of this class. The instance represents a generic adult and has the name "An adult" and the age 21.

Give the complete definition of a class called Person that has two instancevariables, one for the person?s name and the other for the person?sage. Include accessor methods and mutator methods for each instancevariable. Also, include a method that sets both the name and age of aperson. There are no other methods.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT