Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a file called Main.java , add a class called Main, this is a static class and contains our main method Make an abstract class

Make a file called Main.java , add a class called Main, this is a static class and contains our main method


    1. Make an abstract class Animals, include
      1. Private String name
      2. A constructor that takes an argument name
      3. A public method getName
      4. abstract public String behaviour();
    2. Make a class Mammals that extends Animals, include
      1. A constuctor that takes an argument name
      2. An inherited method behaviour that returns " runs on land"
    3. Make a class Birds that extends Animals, include
      1. A constuctor that takes an argument name
      2. An inherited method behaviour that returns " flies in air"
    4. Make a class Fish that extends Animals, include
      1. A constuctor that takes an argument name
      2. An inherited method behaviour that returns " swims in water"



    This is the code i have so far:

    For Main:

    public class Main {

    public static void main(String[] args) { // TODO Auto-generated method stub

    Birds birds = new Birds ("swallow"); Mammals Mammals = new Mammals ("monkey"); Fish Fish = new Fish ("pike"); System.out.println(swallow.getName() + swallow.behaviour()); System.out.println(Monkey.getName() + Monkey.behaviour()); System.out.println(pike.getName() + pike.behaviour()); }

    }

    For Animals:

    public abstract class Animal{ private String name;

    public abstract String behaviour();

    public Animal(String name){ this.name = name; } public String getName(){ return this.name; } }

    For Mammals:

    public class Mammals extends Animal{ public Mammals(String name){ super(name); } public String behavior(){ return "runs on land"; } }


    For Birds:

    public class Birds extends Animal{ public Birds(String name){ super(name); } public String behavior(){ return "flies in air"; } }


    For Fish:

    public class Fish extends Animal{ public Fish(String name){ super(name); } public String behavior(){ return "swims in water"; } }


    I am stuck at this point can you explain the question in detail and also explain where I am going wrong and where to fix it.

    Step by Step Solution

    There are 3 Steps involved in it

    Step: 1

    It looks like youre on the right track with your implementation Lets go through the requirements and make sure everything is implemented correctly 1 M... blur-text-image

    Get Instant Access to Expert-Tailored Solutions

    See step-by-step solutions with expert insights and AI powered tools for academic success

    Step: 2

    blur-text-image_2

    Step: 3

    blur-text-image_3

    Ace Your Homework with AI

    Get the answers you need in no time with our AI-driven, step-by-step assistance

    Get Started

    Recommended Textbook for

    Java Programming

    Authors: Joyce Farrell

    9th edition

    1337397075, 978-1337397070

    More Books

    Students also viewed these Programming questions

    Question

    What are the types of production systems in aquaculture?

    Answered: 1 week ago