Question
Asked by:
$10.00 Java Program
- From Computer-Science: Programming-Methods , Computer-Science: Compilers
- Closed, but you can still post tutorials
- Due on Jul. 29, 2009
- Asked on Jul 28, 2009 at 9:58:29PM
Q:Write a user-defined class called Person. This class should have private instance variables defined as:
private int age;
private String firstName;
private String lastName;
In addition, the class should have a constructor defined as:
public Person(String _firstName, String _lastName, int _age)
that assigns values to the private instance variables. The class should also include the following public methods:
public void printName() prints the person's name
public void printAge() prints the person's age
public void printAgeGroup() prints the persons age group (i.e. 20's. 30's, etc.)
Only include this last method if it is necessary to include logic in the assignment.
Write a second class with the method, public static void main(String args[]). At least two objects based on the Person class should be created in the method. The name, age, and age group should be displayed for each object.



