Site Search:

OCPJP Simulation Test 24

<Back to OCPJP





Question: What is the output of the following program?

  1 class Tool<T> {
  2   public String name;
  3 }
  4 public class ToolBox<U> {
  5   public static <T> Tool<T> solve(T t) {
  6     Tool<T> u = new Tool<T>();
  7     return u;
  8   }
  9   public static <T> T desc(T t) {
 10     return t;
 11   }
 12   public static U idle(U u){return u;}
 13 
 14   public static void main(String...args) {
 15     System.out.print(ToolBox.desc("hammer"));
 16     System.out.print(ToolBox.solve("hammer").name);
 17     System.out.print(ToolBox.<Integer>solve(10).name);
 18     System.out.println(idle("xxx"));
 19   }

 20 }


Choice:
A. compiler error at line 1
B. compiler error at line 4
C. compiler error at line 6
D. compiler error at line 10
E. compiler error at other lines
F. hammerhammer10xxx
G. nullnllnullxxx
H. hammernullnullxxx