exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 100 discussion

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

Given TripleThis.java:



Compiling TripleThis.java gives this compiler warning:

Note: TripleThis.java uses unchecked or unsafe operations.

Which two replacements remove this compiler warning and prints 12? (Choose two.)

  • A. Replace line 12 with public static void printValue(Function f, int num) {
  • B. Replace line 12 with public static void printValue(Function f, T num) {
  • C. Replace line 9 with Function tripler = x —> { return (Integer) x * 3; }
  • D. Replace line 12 with public static void printValue(Function f, Integer num) {
  • E. Replace line 9 with Function tripler = x -> { return x * 3; }
  • F. Replace line 9 with Function tripler = x -> [ return x * 3; ]
Show Suggested Answer Hide Answer
Suggested Answer: AD 🗳️

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
6 months, 3 weeks ago
This code doesn't compiled "T is not found" it will compile if written something like this public static <T extends Integer> void printValue(Function f, T num) { There is no correct answer This code, for example, remove the compile warning : public static void main(String[] args) { Function <Integer, Integer> triple = x -> { return x*3; }; MyClass.printValue(triple, 4); } public static void printValue(Function<Integer, Integer> f, int num) { System.out.println(f.apply(num)); }
upvoted 1 times
ASPushkin
2 months, 1 week ago
"T is not found" use bounded type parameters like <T extends Integer> or change T to Integer or int (A,D) "...uses unchecked or unsafe operations." the reason is using raw code use generics Function<Integer, Integer>
upvoted 1 times
...
...
dilleman
1 year, 3 months ago
Tested, A and D
upvoted 2 times
...
Stavok
1 year, 5 months ago
Selected Answer: AD
A & D are correct
upvoted 2 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