Pregunta de entrevista de KAYAK

Create a list of duck objects: each duck has a different quacking behavior and flying behavior. Write your code on the whiteboard.

Respuesta de la entrevista

Anónimo

9 may 2016

I implemented a Duck class and two interfaces for the quacking behavior (with a quack() method) and the flying behavior (with a fly() method). The constructor of the Duck class receives a quacking behavior object and a flying behavior object (each one of the relevant interface) and stores them.