Question: Write a java class for a Dog with (1) an instance variable MyAge, (2) a constructor that takes in an int for the initial age
Write a java class for a Dog with (1) an instance variable MyAge, (2) a constructor that takes in an int for the initial age of Dog, (3) a method getOlder() to increment the age of the Dog, (4) a method toString () to return a string that say the Dog's age, and (5) a main method that creates a Dog object, called getOlder() and print the Dog.
Please code this in Jave please, Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
