1

what does it mean when

public interface Server extends Remote{

the above code is in place. I understand that the client will call the server but what does it mean for the server to extend remote.

  • possible duplicate of [Interface extends another interface but implements its methods](http://stackoverflow.com/questions/10227410/interface-extends-another-interface-but-implements-its-methods) – Patrick W Apr 21 '15 at 13:32

2 Answers2

2

For implementing a RMI one first need to create the remote interface and provide implementation to the remote interface.

For creating remote interface we need to extend remote interface.

import java.rmi.*;  
public interface RemoteAdder extends Remote{  
 public int add(int x,int y)throws RemoteException;  
}  

Here RemoteAdder is my remote interface created by extending the remote interface.

for more explanation this link may help you:

http://www.javatpoint.com/RMI

Thanks!!

Pushpak
  • 148
  • 5
0

Any class implementing Server will have to provide code to the methods in both the Server and Remote interfaces. to illustrate, given:

public interface interfaceA {
    String AMethod1();
    String AMethod2();
}

and

public interface interfaceB extends interfaceA{
    String BMethod();
}

If I implement interfaceB I will need to add implementations for both interfaceB and interfaceA methods

public class ImplementationClass implements interfaceB {

    @Override
    public String AMethod1() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String AMethod2() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String BMethod() {
        // TODO Auto-generated method stub
        return null;
    }

}
Loco234
  • 521
  • 4
  • 20