• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generic problem

 
Kathy Juyao
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have question on K&B book Chapter7 Q16, see below.

16.
Given a method declared as:

public static <E extends Number> List<? super E> process(List<E> nums)

A programmer wants to use this method like this:

// INSERT DECLARATIONS HERE

output = process(input);


Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)

ArrayList<Integer> input = null;

ArrayList<Integer> output = null;

ArrayList<Integer> input = null;

List<Integer> output = null;

ArrayList<Integer> input = null;

List<Number> output = null;

List<Number> input = null;

ArrayList<Integer> output = null;

List<Number> input = null;

List<Number> output
 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public static <E extends Number> List<? super E> process(List<E> nums)


look at the errata for the K&B book. there is a typo here.
http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated


it should be
public static <E extends Number> List<E> process(List<E> nums)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic