T is place holder that should be filled
that's OK :
public class Computator <N extends Number> {
public N sum (N n) {
return n;
}
that's is not :
public class Computator <N extends Number> {
public N sum () {
double n = 1.1;
return n;
}
Computator<Integer, List<Integer>> c = new Computator<>(); //line 6
N - generic class param type passed as Integer
public N sum (C collection) //line 2
so return type for sum(C collection) is Integer
double sum = 0.0; //line 3
...
retrun sum; //line 7
variable "sum" has a type as a primitive double.
it will be compile error.
answer: D
D is correct, only for safe type N extends of number but the return type is a double, even double extends from a double, Class N can be any class that extends, compilator does unknown the type so prevent this compilator error thworn.
return type must be double
This section is not available anymore. Please use the main Exam Page.1z0-819 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
9 months, 1 week agoASPushkin
6 months agod7bb0b2
1 year, 4 months agoStavok
1 year, 11 months agoRP384
2 years, 3 months ago