Question: Section 2 - Chapter 5 Write a program that creates a Toy class with a string called name set to Mr. Cellophane and int variable

 Section 2 - Chapter 5 Write a program that creates a

Section 2 - Chapter 5 Write a program that creates a Toy class with a string called name set to "Mr. Cellophane" and int variable called number set to 0. Also add a static method called changer to Toy class which takes a Toy object and changes its name and number variables to "Hot Shot" and 42 respectively. Toy class will also have a toString method that returns (name + "" + number) string. The program will print: Mr. Cellophane 0 Now we call changer with an Object as argument. Hot Shot 42

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!