โ Back to 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
Topics:
Abstract ClassesInterfacesInheritanceClasses
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.