Ejercicio 1 lays the foundation of Taller 12 by defining two single-method interfaces —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jhaymayleth/unidad2_java/llms.txt
Use this file to discover all available pages before exploring further.
Volador and Cantante — and then building an Ave class that satisfies both contracts simultaneously. The exercise shows that a class is not limited to one role: a bird in the real world both flies and sings, and Java’s multiple interface implementation lets the code reflect that reality directly.
The Interfaces
Each interface declares exactly one method. There is no implementation, no state — just a named capability that any willing class can adopt.Volador.java — anything that can fly:
Cantante.java — anything that can sing:
The Ave Class
Ave declares implements Volador, Cantante, meaning it must provide a concrete body for both volar() and cantar(). It also carries two private fields — nombre and especie — that are set through its constructor and referenced in the method output strings.
Usage — Ejercicio1.java
The main class constructs a single Ave and calls both interface methods on it:
Polymorphism Through Interfaces
BecauseAve implements both Volador and Cantante, an Ave object IS-A Volador and IS-A Cantante at the same time. Either interface type can be used as the declared variable type, and the JVM will dispatch to Ave’s implementation at runtime:
Volador parameter will work correctly whether you pass an Ave or any other future class that also implements Volador.