Site Search:

OCPJP Simulation Test 22

<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     u.name = "drill";
  8     return u;
  9   }
 10   public static <T> T desc(T t) {
 11     return t;
 12   }
 13   public static <T> void idle(T t){}
 14 
 15   public static void main(String...args) {
 16     System.out.print(ToolBox.desc("hammer"));
 17     System.out.print(ToolBox.solve("hammer").name);
 18     System.out.print(ToolBox.<Integer>solve(10).name);
 19     ToolBox.<String>idle("xxx");
 20   }
 21 }


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. hammerhammer10
G. hammerdrill10
H. hammerdrilldrill