Skip to content
Quiz · Interfaces, enums and records · lesson 2 of 8

Quiz — an interface method not written

What happens when this program is compiled and run?

JAVA
public class Main {
    public static void main(String[] args) {
        Machine r = new Robot();
        r.start();
        r.stop();
        System.out.println("end");
    }
}
interface Machine { void start(); void stop(); }
class Robot implements Machine {
    public void start() { System.out.print("go "); }
}