017-005-008
Resolving Diamond Inheritance Problem
Hard
Problem Description
Resolving Diamond Inheritance Problem
Learning Objective: Understand how to resolve conflicts when multiple interfaces have default methods with the same signature
Overview
Resolve the conflict when two interfaces Walker and Swimmer have default methods move() with the same signature.
Specifications
Walkerinterface: default methodmove()outputs "Walking"Swimmerinterface: default methodmove()outputs "Swimming"Amphibianclass: implements both interfaces- Override
move()to output "Walking and Swimming" walkOnly()method calls Walker.super.move()swimOnly()method calls Swimmer.super.move()
- Override
- In
main, call all three methods
Output Format
Walking and Swimming
Walking
Swimming
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
