49.5k views
1 vote
1. Create an interface called Runner. The interface has an abstract method called run() that display a message describing the meaning of "run" to the class. Create classes called Machine, Athlete, PoliticalCandidate that all implement Runner. Create an application that demonstrates the use of the classes. Save the files as Runner.java, Machine.java, Athlete.java, PoliticalCandidate.java and DemoRunners.java

1 Answer

7 votes

Answer:

see explaination for program code

Step-by-step explanation:

interface Runner

{

public abstract void run();

}

class Machine implements Runner

{

public void run()

{

System.out.println("Machine is running");

}

}

class Athlete implements Runner

{

public void run()

{

System.out.println("Athlete is running");

}

}

class PoliticalCandidate implements Runner

{

public void run()

{

System.out.println("Political Candidate is running");

}

}

class DemoRunners

{

public static void main (String[] args)

{

Machine m = new Machine();

m.run();

Athlete a = new Athlete();

a.run();

PoliticalCandidate pc = new PoliticalCandidate();

pc.run();

}

}

User Gwendolyn
by
7.4k points