017-005-007

Basic Multiple Interface Implementation

Easy

Problem Description

Basic Multiple Interface Implementation

In this problem, you will create a program that implements both Swimmable and Flyable interfaces in a Duck class, then calls each interface method and displays the results to standard output.

Learning Objective: Understand how to implement multiple interfaces in a single class

Overview

Create a Duck class that implements both Swimmable and Flyable interfaces.

Specifications

  • Swimmable interface: has void swim() method
  • Flyable interface: has void fly() method
  • Duck class: implements both interfaces
  • swim() outputs "Duck is swimming"
  • fly() outputs "Duck is flying"
  • In main method, create a Duck instance and call both methods

Output Format

Duck is swimming
Duck is flying

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up