public interface Vehicle {
public void start();
public void stop();
}
public interface Motorized {
public void stop();
public void slow();
}
public class Car implements Vehicle,Motorized {
public void start(){};
public void stop(){};
public void slow(){};
}
What is the result of invoking Car’s stop method?
A.
Both vehicles and Motorized’s stop methods are invoked.
B.
Vehicles stop method is invoked.
C.
Motorized’s stop method is invoked.
D.
The implementation of the Car’s stop determines the behavior.
E.
Compilation fails.
La Risposta è D
Infatti per definizione i metodi
non possono essere implementati nelle interfacce ma sono nelle classi. Quindi l’unica
implementazione possibile è dentro la classe Car.
Nessun commento:
Posta un commento