Question: 1 - Create a constructor in the Dog class that takes two input parameters and uses those parameters to initialize the instance variables. 2 -

1-Create a constructor in the Dog class that takes two input parameters and uses those parameters to initialize the instance variables.
2- In the main method inside the driver class, declare a variable of type Dog (call it myDog) and instantiate it with values of your choice.
3-In the main method inside the driver class, declare a variable of type Dog (call it yourDog). Instantiate it with appropriate values so that it represents a 2 year old bulldog.
4-Add a getter for all of the variables of the dog class. Add a setter for all of the variables of the dog class.
5-When should your class have a getter for a variable? When should your class have a setter for a variable?
6- Create a toString() method for your Dog class. What sentence will you use to describe the dog?
7- Add a static counter to the dog class. Create a variable to hold the dogs id.
Update the constructor(s) to use the static variable to assign a unique id to every dog that is created.
8- Add an equals() method to the dog class. Two dogs should be considered equal if they have the same id.
9- Suppose that x , y and z are all Double objects. Describe all the boxing and unboxing that occurs in the assignment z = x + y

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 Programming Questions!