exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 39 discussion

Actual exam question from Oracle's 1z0-819
Question #: 39
Topic #: 1
[All 1z0-819 Questions]

Given the code fragment:

Which action enables Computator class to compile?

  • A. change Line 1 to add throws NumberFormatException
  • B. change Line 3 to Double sum = 0.0;
  • C. change Line 5 to List<Double> numbers = List.of(5, 4, 6, 3, 7, 2, 8, 1, 9);
  • D. change Line 2 to public Double sum ( C collection) {
  • E. change Line 4 to for (Double n : collection) {
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
3 months, 3 weeks ago
Selected Answer: D
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; }
upvoted 1 times
ASPushkin
2 weeks, 1 day ago
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
upvoted 1 times
...
...
d7bb0b2
11 months ago
Selected 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
upvoted 1 times
...
Stavok
1 year, 6 months ago
Selected Answer: D
D is correct, Tested
upvoted 1 times
...
RP384
1 year, 10 months ago
Selected Answer: D
return type should be Double and not N
upvoted 1 times
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago