Question: use Java Language JAVA LANGUAGE ONLY Please write code that meets the following requirements: Create an abstract class called Animal Has private attributes numLegs (int),

use Java Language

JAVA LANGUAGE ONLY

Please write code that meets the following requirements:

Create an abstract class called Animal

Has private attributes numLegs (int), name (String)

Create a constructor that requires both parameters

Has getters for numLegs and name (but not setters)

Has a toString() method implemented (use NetBeans for this)

Has public abstract boolean method called isFast()

Create a concrete class called Tortoise

Inherits from Animal

Implements only one constructor (which requires name)

Implements isFast(), returns false

Calls Animal constructor with name and legs=4

Create a concrete class called Ostrich

Inherits from Animal

Implements only one constructor (which requires name)

Implements isFast(), returns true

Calls Animal constructor with name and legs=2

Create a class Main which has a main method like this:

 public static void main(String[] args) { Animal a1 = new Tortoise("Terry the Tortoise"); Animal a2 = new Ostrich("Olga the Ostrich"); System.out.println(a1); System.out.println(a2); 

}

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!