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 (...) {}
}
```

Computer Science & Information Technology

You might also like to view...

Answer the following questions true (T) or false (F)

1. The Standard Template Library consists of the containers of various kinds. 2. The STL containers each define iterators appropriate to the internal structure of the container.

Computer Science & Information Technology

Database design is considered to be a three-step process

Indicate whether the statement is true or false

Computer Science & Information Technology

To add a WordArt image to a worksheet, you click the WordArt button in the:

A) Illustrations group on the Home tab. B) Text group on the Insert tab. C) Text group on the Home tab. D) Illustrations group on the Insert tab.

Computer Science & Information Technology

In September 1999, the IEEE ratified the 100-gigabit Ethernet standard.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology