permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP 5 K&B question problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP 5 K&B question problem" Watch "SCJP 5 K&B question problem" New topic
Author

SCJP 5 K&B question problem

Abdul Mohsin
Ranch Hand

Joined: Apr 26, 2007
Posts: 111

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


Regards, Abdul Mohsin
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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


cmbhatt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP 5 K&B question problem
 
Similar Threads
Generic doubt
Generics Question
Doubt in Generics
doubt abt Generics mock question - from K&B
generic, self test example