Use classes Class and Method. Use type RemoteObjectRef as type of instance variable. The class Class has method getMethod whose arguments give class name and an array of parameter types. The proxy’s vote method, should have the same parameters as the vote in the remote interface - that is: two parameters of type String and int. Get the object representing the vote method from the class Election and pass it as the second argument of doOperation. The two arguments of vote are converted to an array of byte and passed as the third argument of doOperation.
What will be an ideal response?
```
import java.lang.reflect;
class VoteProxy { RemoteObjectRef ref;
private static Method voteMethod; private static Method resultMethod; static {
try {
voteMethod = Election.class.getMethod ("vote", new Class[]
{java.lang.String.class,int.class}));
resultMethod = Election.class.getMethod ("result", new Class[] {}));
}catch(NoSuchMethodException){}
}
public void vote (String arg1, int arg2) throws RemoteException {
try {
byte args [] = // convert arguments arg1 and arg2 to an array of bytes
byte result = DoOperation(ref, voteMethod, args);
return ;
} catch (...) {}
}
```
You might also like to view...
The default calculation setting is ________
Fill in the blank(s) with the appropriate word(s).
An adult day care facility provides a residence for disabled and elderly patients who need medical supervision or ongoing nursing care
Indicate whether the statement is true or false