IDL-to-Java mapping for sequences - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. How does the mapping of bounded and unbounded sequences differ?
Please select the best answer.
  A. The arrays produced by bounded sequences are length checked everywhere they are used.
  B. The arrays produced by bounded sequences are length checked when they are marshaled.
  C. The arrays produced by unbounded sequences are length checked in the client.
  The correct answer is B. The only difference between the mappings for bounded and unbounded sequences is that bounded sequences are length checked when marshalling. A is incorrect because the generated arrays are not checked (and cannot be checked) everywhere they are used. C is incorrect because unbounded sequences are not length checked.

2. What will the ClubBouncerOperations Java interface generated by the following IDL be?
module Module4
{
 //Sequence of names
 typedef sequence<string> NameList;
 
 interface ClubBouncer
     {
  //Takes list of names, pushes back out with un-hip names removed
  void approvePeople(inout NameList clubGoers);
     };
}; 

Please select the best answer.
  A.
package Module4;
public interface ClubBouncerOperations
{
 public void approvePeople(Module4.NameListHolder clubGoers);
}
  B.
package Module4;
public interface ClubBouncerOperations
{
 public void approvePeople(java.lang.String[] clubGoers);
}
  C.
package Module4;
public interface ClubBouncerOperations
{
 public void approvePeople(NameList clubGoers);
}
  The correct answer is A. The correct answer is A, because clubGoers is an inout parameter, so what will be passed in Java will be the holder class for the sequence type. If clubGoers had been an in parameter, then the answer would have been B, in which the sequence is simply mapped to the corresponding Java array. B is incorrect because clubGoers is an inout and not an in parameter. C is incorrect because there is no Java "sequence class" for an IDL sequence, only corresponding arrays and helper and holder classes.

3. Which of the following Java code fragments represents correct possible client code for the ClubBouncer interface in the following IDL?
module Module4
{
 //Sequence of names
 typedef sequence<string> NameList;
 
 interface ClubBouncer
     {
  //Takes list of names, pushes back out with un-hip names removed
  void approvePeople(inout NameList clubGoers);
     };
}; 

Please select the best answer.
  A.
//Initialize ORB ..
  ClubBouncer bouncer = null;
  //Obtain reference to remote ClubBouncer ..
  String[] wannabes = {"Mark", "Gordon", "Madonna"};
  bouncer.approvePeople(wannabes);
  System.out.println("They'll only let in
"+wannabes.length+" of us");
  // ...
  B.
//Initialize ORB ..
  ClubBouncer bouncer = null;
  //Obtain reference to remote ClubBouncer ..
  String[] wannabes = {"Mark", "Gordon", "Madonna"};
  NameListHolder listParam = new NameListHolder(wannabes);
  bouncer.approvePeople(listParam);
  System.out.println("They'll only let in
"+listParam.value.length+" of us");
  // ...
  C.
//Initialize ORB ..
  ClubBouncer bouncer = null;
  //Obtain reference to remote ClubBouncer ..
  NameList wannabes = new NameList("Mark", "Gordon", "Madonna");
  NameListHolder listParam = new NameListHolder(wannabes);
  bouncer.approvePeople(listParam);
  System.out.println("They'll only let in
"+listParam.value.length+" of us");
  // ...
  The correct answer is B. NameListHolder is used because the approvePeople() operation has an inout parameter. A is incorrect because it does not use the holder. C is incorrect because it uses a nonexistent sequence class NameList instead of the array to which the sequence is actually mapped.