In the previous chapter, Self-Test Question 16 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.

See the code in Person.java.

Computer Science & Information Technology

You might also like to view...

A Watermark is a graphic inserted into the ________ of a workbook

A) header B) footer C) margin D) sheet tab

Computer Science & Information Technology

A company is having a new T1 line installed. Which of the following will the connection MOST likely terminate to?

A. Core switch B. MDF C. Ethernet router D. IDF

Computer Science & Information Technology