Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java language. Write a class Animal that stores a String name and an int age. Write a constructor that takes parameters for name and age
java language.
Write a class Animal that stores a String name and an int age. Write a constructor that takes parameters for name and age and initializes the name and age. Write a toString method that, for a stored name of "David" and age of 2, would return exactly "name: David age: 2". Test your class by making an Animal with a name of "David" and an age of 2 and then printing it. 1. 2. Write a class Holdlt that stores an instance of a generic object type. Write a constructor that initializes this stored value with a passed in parameter. Write a toString method that prints that stored value and only the stored value. Test your code by making an instance that holds a name "David" and another instance that holds an int 2. Print out both instances. 3. Write a class Cat that inherits from Animal. Write a constructor with no parameters that uses the Animal constructor to set name to "Kitty" and age to 0. Override the toString method to return the Animal toString followed by says: Meow". In main, make a Cat and print it out. Make a GUI in a class called GUITest that uses a JFrame and adds a quit button. If the quit button is pressed, the program should close. 4Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started