Operations interface mapping - Quiz Explanation

The correct answers are indicated below, along with the text that explains the correct answers.
 
1. What Java operations interface is produced by the following IDL?
module weather
{ 
 interface WeatherService
     {
  attribute long citiesCovered;
  string getReport(in string city);
     };
};


Please select the best answer.
  A.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city);
}

  B.
package weather;
public interface WeatherServiceOperations
{
 public int citiesCovered();
 public void citiesCovered(int arg);
 public java.lang.String getReport(java.lang.String city);
}
  C.
package weather;
public interface WeatherServiceOperations
{
 public long citiesCovered();
 public void citiesCovered(long arg);
 public java.lang.String getReport(java.lang.String city);
}
  The correct answer is B.
The interface in B captures the methods mapped from IDL including the accessor and mutator for the given attribute. A is incorrect because it lacks the methods for the attribute. C is incorrect because the IDL long maps to a Java int, not a Java long.

2. What Java operations interface will be produced by the following IDL?
module weather
{ 
 interface WeatherService
     {
  string getReport(in string city, out long temperature);
     };
};

Please select the best answer.
  A.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city,
  int temperature);
}
  B.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city,
  org.omg.CORBA.LongHolder temperature);
}
  C.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city,
  org.omg.CORBA.IntHolder temperature);
}
  The correct answer is C. C is correct because an IDL long maps to a Java int, and an out parameter is mapped to the corresponding holder class, IntHolder for an int. A is incorrect because it does not correctly map the out parameter to a holder. B is incorrect because IDL longs map to Java ints, not longs.

3. What Java operations interface will be produced by the following IDL?
module weather
{ 
 interface WeatherService
     {
  const string tempUnits = "farenheit";
  string getReport(in string city);
     };
};

Please select the best answer.
  A.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city);
}
  B.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city);
 java.lang.String tempUnits = "farenheit";
}
  C.
package weather;
public interface WeatherServiceOperations
{
 public java.lang.String getReport(java.lang.String city);
 java.lang.String getTempUnits();
}
  The correct answer is A. A is correct because const does not map to a method in fact, it maps to a field in the signature interface. B is incorrect because the operations interface has only mapped methods; the field would be generated in the signature interface. C is incorrect because const does not map to a method, it maps to a field, and fields do not appear in the operations interface.