Site Search:

OCPJP Simulation Test 16

<Back to OCPJP





Question: What is the output of the following program?

  1 public class Wrap<T> {
  2   T value;
  3   public Wrap(T value) {
  4     this.value = value;
  5   }
  6   public T getValue() {
  7     return value;
  8   }
  9   public static void main(String args[]) {
 10     Wrap<String> one = new Wrap<String>("some value");
 11     Wrap<Integer> two = new Wrap<>(1234);
 12     System.out.print(one.getValue());
 13     System.out.print(two.getValue());
 14 }}

Choice:
A. some value1234
B. some value0
C. some valuenull
D. compiler error on line 1
E. compiler error on line 10
F. compiler error on line 11
G. runtime exception on line 12
H. runtime exception on line 13