Java question f Consider the following interfaces interface Run public void runO
ID: 3743048 • Letter: J
Question
Java question f
Consider the following interfaces interface Run public void runO; interface Cycle [ public void cycleO; interface Swim extends Cycle, Run [ public void fastSwim; public void slowSwimO; Write a class Triathlete that implements the swim interface. Simply prints the name of the method on a single line in each methoo. Write the entire Triathlete class in the answer box below assuming that all interfaces have been done for you. For example: Test Result Triathlete t new Triathlete fastSwim t.fastSwimO; t.slowSwimO slowSwimExplanation / Answer
interface Run {
public void run(); // declaration..signature
}
interface Cycle {
public void cycle(); // declaration..signature
}
interface Swim extends Run, Cycle {
public void fastSwim(); // declaration..signature
public void slowSwim(); // declaration..signature
}
class Triathlete implements Swim {
public void run() { //body..definition
}
public void cycle() { //body..definition
}
public void fastSwim() { //body..definition
System.out.println("fastSwim");
}
public void slowSwim() { //body..definition
System.out.println("slowSwim");
}
}
Triathlete t = new Triathlete();
t.fastSwim();
t.slowSwim();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.