Working with methods receiving interfaces as arguments
In the previous chapter, we created the following five interfaces: DrawableInComic
, DrawableInGame
, Hideable
, Powerable
, and Fightable
. Then, we created the following classes that implemented different interfaces, and, many of them, also inherited from superclasses: SpiderDog
, WonderCat
, HideableWonderCat
, PowerableWonderCat
, and FightableWonderCat
.
Run the following command in JShell to check all the types we have created:
/types
The following screenshot shows the results of executing the previous command in JShell. JShell enumerates the five interfaces and the five classes we have created in the session.

When we work with interfaces, we use them to specify the argument types instead of using class names. Multiple classes might implement a single interface, and therefore, instances of different classes might qualify as an argument of a specific interface.
Now we will create additional instances of the previously mentioned classes and we...