how to create a class called Cheetah that:
inherits from the Animal class.
makes use of at least one static field which needs to have a static
setter and getter.
Contains a toString ()method.
Has an array as one of it's field.
.Create an application class, and within it create a Cheetah object and print it out with the main method
class Animal { private String name; private int age; public Animal(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } class Cheetah extends Animal { private static int speed; public Cheetah(String name, int age) { super(name, age); } public static int getSpeed() { return speed; } public static void setSpeed(int speed) { Cheetah.speed = speed; } } class CheetahTest { public static void main(String[] args) { Cheetah cheetah = new Cheetah("Tom", 5); Cheetah.setSpeed(56); System.out.println("Name: " + cheetah.getName()); System.out.println("Age: " + cheetah.getAge()); System.out.println("Speed: " + Cheetah.getSpeed()); } }
Get Answers For Free
Most questions answered within 1 hours.