Question: A + Computer Science - Writing Classes Worksheet 2 DIRECTIONS : Fill in each blank with the proper java code. class Pet { private String

A+ Computer Science - Writing Classes Worksheet 2
DIRECTIONS : Fill in each blank with the proper java code.
class Pet
{
private String name;
private int age;
public Pet(String n, int a)
i
(1)
}
public void setAge( int a )
{
(2)
}
public void setName ( String n )
q
(3)
}
public String getName()
q
(4)
}
public int getAge()
q
(5)
}
public string tostring()
{
(6)
}
}//runner code
Scanner kb = new Scanner (System.in);
for (int r=1; r=5; r++){
System.out.print (" Enter a pet name ::");
String n = kb.next();
System.out.print (" Enter a pet age ::");
String n = kb.nextInt();
Pet pet = new Pet( n, a );
System.out.println (pet);
}
 A+ Computer Science - Writing Classes Worksheet 2 DIRECTIONS : Fill

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!