Answer and Explanation:
public class petData
{
private int ageYears;
private String fullName;
private int IdNumber;
public void setName (String givenName)
{
fullName = givenName;
return;
}
public void setAge (int numYears)
{
ageYears = numYears;
return;
}
public void setID (int numID)
{
IdNumber = numID;
return;
}
public void printAll ()
{
System.out.print ("Name: " + fullName);
System.out.print (", Age: " + ageYears);
return;
}
}
From the above, we have defined a class petData, with methods setName, setAge, printAll. These methods all make use of the string variable fullName and integer variable ageYears. From the above, setName method sets fullName variable to name given to its string parameter givenName while setAge method does the same with the ageYears variable in initializing it. This is also done by the ID method. These variables are then used by printAll method in printing out the Name and age of the object which would be created with the petData class
E. g: petData dog= new petData();