Answer to Question #205085 in Java | JSP | JSF for umme habiba sumi

Question #205085

(Abstract class, Interface, Method Overriding)Write a java program with proper

illustration to implement the following instructions:

a) Create an interface named Animals which declare a void method callSound() and a

int method run().

b) Create an abstract class Feline that implements Animals, then override the

callSound() method and print “roar”.

c) Create an abstract class Canine that implements Animals, then override the

callSound() method and print “how1”.

d) Create a class Lion that extends Feline, then override the callSound() method and

refer immediate parent class callSound() method , also override the run() method and

return 40.



1
Expert's answer
2021-06-10T01:37:23-0400
public interface Animals {
    void callSound();

    int run();
}


public abstract class Feline implements Animals{
    @Override
    public void callSound() {
        System.out.println("roar");
    }
}


public abstract class Canine implements Animals{
    @Override
    public void callSound() {
        System.out.println("howl");
    }
}


public class Lion extends Feline{
    @Override
    public void callSound() {
        super.callSound();
    }

    @Override
    public int run() {
        return 40;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS