aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in super keyword in Genrics 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 "doubt in super keyword in Genrics" Watch "doubt in super keyword in Genrics" New topic
Author

doubt in super keyword in Genrics

Arul Prasad
Ranch Hand

Joined: Jan 20, 2005
Posts: 57
in Lesson No 7 and for the question no 16 i have a doubt

question was ...

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.

Answer:
B, E, and F are correct.


but i 'm getting the compile error can any aone help me ...


Error ..
------------
TestColl.java:23: incompatible types
found : java.util.List<capture of ? super Base>
required: java.util.List<Base>
List<Base> subList = print(bList);
^
1 error





It was compiled after the change in line 23 as


now i need to know about the correct answer and also the use of the super keyword ....

is there anyone help me


With Regards<br />Arul
 
wood burning stoves
 
subject: doubt in super keyword in Genrics