Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 slowSwim

Explanation / 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();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote