Interfejs Java zgłasza wyjątek, ale implementacja interfejsu nie rzuca wyjątku?
Czytam ten kod, w którym interfejs zgłasza wyjątek, ale klasa, która go implementuje, nie rzuca ani nie łapie jednego, dlaczego tak jest? Czy jest to legalne lub bezpieczne w Javie?
import java.rmi.*;
public interface MyRemote extends Remote {
public String sayHello() throws RemoteException;
}
import java.rmi.*;
import java.rmi.server.*;
public class MyRemoteImpl extends UnicastRemoteObject implements MyRemote{
public String sayHello() {
return "Server says, 'Hey'";
}
public MyRemoteImpl() throws RemoteException {}
public static void main (String[] args) {
try {
MyRemote service = new MyRemoteImpl();
Naming.rebind("RemoteHello", service);
} catch(Exception ex)
{
ex.printStackTrace();
}
}
}