IDL-to-Java mapping for structs - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Running IDL containing a struct called Foo through the IDL compiler will generate what set of corresponding Java files ?
Please select the best answer.
  A. FooHelper.java, FooHolder.java, and FooStruct.java
  B. FooStruct.java
  C. FooHolder.java, Foo.java, and FooHolder.java
 

The correct answer is C.


The Java class name is the same as the IDL struct name, and corresponding helpers and holders are generated for structs. A is incorrect because the name of the Java class for the struct is simply the same as the name of the struct. B is incorrect because it does not include the helper and holder class files. D is incorrect because the helper and holder classes for X are XHelper and XHolder.

2. The struct in the following IDL will result in which of the following possible Java files?
module Module4
{
 struct Bar
 {
  string name;
  long height;
 };
};

Please select the best answer.
  A.
package Module4;
public final class Bar
 implements org.omg.CORBA.portable.IDLEntity
{
 private java.lang.String name;
 private int height;
 public Bar(){}
 public Bar(java.lang.String name, int height)
 {
  this.name = name;
  this.height = height;
 }
}
  B.
package Module4;
public final class Bar
 implements org.omg.CORBA.portable.IDLEntity
{
 public java.lang.String name;
 public int height;
 public Bar(){}
 public Bar(java.lang.String name, int height)
 {
  this.name = name;
  this.height = height;
 }
}
  C.
package Module4;
public final class Bar
 implements org.omg.CORBA.portable.IDLEntity
{
 public java.lang.String name;
 public long height;
 public Bar(){}
 public Bar(java.lang.String name, long height)
 {
  this.name = name;
  this.height = height;
 }
}
 

The correct answer is B.

The correct answer is B, because it adheres to the IDL-to-Java mapping. A is incorrect because the fields should be public, not private structs are just baskets of data. C is incorrect because IDL longs are mapped to Java ints, not longs.

3. The struct in the following IDL will result in which of the following possible Java files?
module Module4
{
 struct Temperature
 {
  string units;
  double val;
 };
};

Please select the best answer.
  A.
package Module4;
public final class Temperature
 implements org.omg.CORBA.portable.IDLEntity
{
 public java.lang.String units;
 public double val;
 public Temperature(){}
 public Temperature(java.lang.String units, double val)
 {
  this.units = units;
  this.val = val;
 }
}
  B.
package Module4;
public class Temperature
 implements org.omg.CORBA.portable.IDLEntity
{
 public java.lang.String units;
 public double val;
 public Temperature(){}
 public Temperature(java.lang.String units, double val)
 {
  this.units = units;
  this.val = val;
 }
}
  C.
package Module4;
public final class Temperature
 implements org.omg.CORBA.portable.IDLEntity
{
 public java.lang.String units;
 public double val;
 public Temperature(java.lang.String units, double val)
 {
  this.units = units;
  this.val = val;
 }
}
 

The correct answer is A.

The correct answer is A, because it adheres to the IDL-to-Java mapping. B is incorrect because the Java class generated for an IDL struct is final. C is incorrect because it lacks the required no-args constructor.