• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJP 5 K&B question problem

 
Abdul Mohsin
Ranch Hand
Posts: 111
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anybody tried running question 16th of chapter 7 kathy Sierra?

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.)
A. ArrayList<Integer> input = null;
ArrayList<Integer> output = null;
B. ArrayList<Integer> input = null;
List<Integer> output = null;
C. ArrayList<Integer> input = null;
List<Number> output = null;
D. List<Number> input = null;
ArrayList<Integer> output = null;
E. List<Number> input = null;
List<Number> output = null;
F. List<Integer> input = null;
List<Integer> output = null;
G. None of the above.


According to book
B, E, and F are correct.

but I tried and found none of them are correct
Please help me
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it is,

public static <E extends Number> List<E> process<List<E> nums)


See the link K&N errata top of this forum!




Thanks,
cmbhatt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic