Oracle
1Z0-819 · Question #183
1Z0-819 Question #183: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #183. The question stem and answer options stay visible for context.
Question
Given TripleThis.java:
1 import java.util.function.*;
2
3 public class TripleThis {
4 public static void main(String[] args) {
5 Function<Integer, Integer> tripler = x -> { return (Integer) x * 3; };
6 TripleThis.printValue(tripler, 4);
7 }
8
9 public static <T> void printValue(Function<T, T> f, T num) {
10 System.out.println(f.apply(num));
11 }
12 }
Note: TripleThis.java uses unchecked or unsafe operations.
Which two replacements done together remove this compiler warning?
Options
- AReplace line 9 with
function<Integer> tripler = x -> { return (Integer) x * 3; }; - BReplace line 12 with
public static void printValue (Function<Integer, T> num) { - CReplace line 12 with
public static <T> void printValue (Function<T, T> f, T num) { - DReplace line 12 with
public static <T> void printValue (Function<T, T> f, T num) { - EReplace line 9 with
function<Integer, Integer> f = x -> { return (Integer) x * 3; };
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.