X1102: Debugging Scope- Dog toString()

The following Dog class stores a String name and an integer numSpots that represents how many spots the dog has on its fur. It also includes a toString() method. For example:

Dog charlie = new Dog("Charlie", 3);

Invoking charlie.toString() should return "Charlie has 3 spots!", but the method is not working correctly. Fix the toString() method.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.