Site Search:

OCPJP Simulation Test 47

<Back to OCPJP





What is the output of the following program?

  1 import java.util.*;
  2 public class Fruits{
  3   public static void print1(List<?> list) {
  4     System.out.print("1" + list.size());
  5     System.out.print(list);}
  6   public static <T>void print2(List<T> list) {
  7     System.out.print("2" + list.size());
  8     System.out.print(list);}
  9   public static void main(String[] args) {
 10     List<String> fruits = new ArrayList<>();
 11     fruits.add("apple"); fruits.add("orange");
 12     print1(fruits);
 13     print2(fruits);}}

Choice:
A. 11appleorange22appleorange
B. 11appleorange21appleorange
C. 12appleorange22appleorange
D. 12[apple, orange]22[apple, orange]
E. compiler error at line 3
F. compiler error at line 6
G. compiler error at line 12
H. compiler error at line 13