SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Yuan Du wrote:why the return type of process must be a List, not ArrayList or LinkedList or something else, which inherits from List?
You are !!!Yuan Du wrote:because List cannot be assigned to ArrayList or LinkedList. Am i right?
SCJP 5
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Maurice Le Chat wrote:I would say the only correct answer to this question is:
G.) None of above.
The only way to compile a copy of this snippet within eclipse results in:
List<Integer> input = null;
List<? super Integer> output = null;
or
List<Integer> input = null;
List<? extens Number> output = null;
when the method call is changed to:
public static <E extends Number> List<? extends E> process(List<E> nums){
would be nice to hear opinions.
Maurice
All code in my posts, unless a source is explicitly mentioned, is my own.
Ruben wrote: The upper bound on the wildcard determines the lowest (in the class hierarchy) reference type you can assign an element to, whereas the lower bound on the wildcard determines the highest (in the class hierarchy) reference type of elements that you can add to the collection. (You also would need to consider interfaces, by the way, I'm simplifying the discussion by only talking about classes.)
List<? extends Number> list=null;
List<? super Integer> list=null;
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
Ruben Soto wrote: 1. Based on the upper bound (Object):
a. We can assign an element of the collection to only a reference variable of type Object.
SCJP 6
Punit Singh wrote:
Ruben Soto wrote: 1. Based on the upper bound (Object):
a. We can assign an element of the collection to only a reference variable of type Object.
What you want to say here?
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
Ruben Soto wrote:You are right Punit. I need to use more examples and less descriptions. Even the JLS has more examples than my posts. :lol:
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
Ruben Soto wrote:Punit, I want to take my exam soon, maybe in the next few weeks. The problem is that the more I learn the more I realize I don't know, but I think you need to stop at some point and just go for it.
Prav sharma wrote:I went through same situation few days back. But finally i fixed a day and stuck to it.
Don't be scared. Just revise what you have practiced all these days.
Cheers !!!
Ruben Soto wrote:Punit, I want to take my exam soon, maybe in the next few weeks. The problem is that the more I learn the more I realize I don't know, but I think you need to stop at some point and just go for it.
All code in my posts, unless a source is explicitly mentioned, is my own.
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|