CodeGym /Courses /Java Core /Practice with abstract classes

Practice with abstract classes

Java Core
Level 3 , Lesson 6
Available

"Hello, Amigo! Here I am. And I've brought you ... a big and interesting task about multiple inheritance."

3
Task
Java Core, level 3, lesson 6
Locked
Tom, Jerry and Spike
Use class and interfaces to implement the relationship between Tom, Jerry and Spike the Bulldog. The cat can move, eat, or be eaten. The mouse can move and be eaten. And the dog can move and eat (whoever it wants!).
Comments (8)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Justin Smith Level 41, Greenfield, USA, United States
31 July 2021
For a "big task" I was surprised how easy this one was. Nothing you haven't done before in previous easy tasks.
Johannes Level 27, Centurion, Pretoria, South-Africa
21 March 2020
It is SOOOOooooo overcomplicated ? Sorry, I know I am complaining, and still a newbie in Java. But why not simplify it and use methods ? eat(), move(), etc.
Angus McDonald Level 5, Sydney, Australia Expert
8 May 2020
Finding this tricky also.. but I suspect because methods (eg. Run) are housed within classes (eg. Dog) and are accessible specifically by the object that's been created using that class (eg. Dog.run). Interfaces create a publicly available "method" (if its easier to refer to them that way) that allow classes of all kinds to use them ("inherit"). Eg. a Cat, a Dog, a Mouse can all access the same "Run" action because its programming sits outside the Cat/Dog/Mouse classes. I think that's how it works. Could be wrong ha!
Jonaskinny Level 25, Redondo Beach, United States
26 February 2022
Porymorphic benefits via interfaces over inheritance
Oregano Level 24, Warsaw, Poland
11 January 2020
THAT was a big task? :)
Muhammad Vahhaaj Level 19, Rawalpindi, Pakistan
10 July 2019
Alright, from the preceding topics what i conclude about: Abstraction - is that it is used to create an idea of a system of classes, where we can make fundamental methods that the inheriting class can implement in its own way and we can also define implemented methods that are already common in all the derived classes Interfaces - is much like abstraction but is used to define roles/methods that specific classes can implement in their own style and it is through these roles, using the mechanism of abstraction and polymorphism, we interact with objects of other classes.
Devonte A Level 18, Rubery, United Kingdom
1 July 2020
Yes you got it!
Muhammad Vahhaaj Level 19, Rawalpindi, Pakistan
10 July 2019
Hmm, not so big