← Back to Abstract Classes
Question 205
Zoo Exhibit with Abstract Animals and Feedable Interface
Zoo Exhibit with Abstract Animals and Feedable Interface
Build a small zoo exhibit system. 1. Create an interfaceFeedablewith a methodString food(). 2. Create an abstract classZooAnimalthat implementsFeedable. It has aprotected String nameand a constructor. It declares an abstract methodString exhibit()but does NOT implementfood()— subclasses must implement both. 3. CreateLionextendingZooAnimal. Constructor takesname.exhibit()returns"Savanna".food()returns"meat". 4. CreatePenguinextendingZooAnimal. Constructor takesname.exhibit()returns"Arctic".food()returns"fish". Do NOT write a main method.
Expected Output:
Simba lives in Savanna and eats meat Tux lives in Arctic and eats fish
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Abstract ClassesInterfacesInheritanceClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.