exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 4 discussion

Actual exam question from Oracle's 1z0-809
Question #: 4
Topic #: 2
[All 1z0-809 Questions]

Given:
class Bird {
public void fly () { System.out.print("Can fly"); }
}
class Penguin extends Bird {
public void fly () { System.out.print("Cannot fly"); }
}
and the code fragment:
class Birdie {
public static void main (String [ ] args) {

fly( ( ) -> new Bird ( ));
fly (Penguin : : new);
}
/* line n1 */
}
line n1, enables the Birdie class to compile?
Which code fragment, when inserted at

  • A. static void fly (Consumer<Bird> bird) { bird :: fly (); }
  • B. static void fly (Consumer<? extends Bird> bird) { bird.accept( ) fly (); }
  • C. static void fly (Supplier<Bird> bird) { bird.get( ) fly (); }
  • D. static void fly (Supplier<? extends Bird> bird) {
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
steefaand
5 months, 4 weeks ago
Selected Answer: C
C and D both compile.
upvoted 1 times
...
Abdullah_Rahahleah
3 years, 7 months ago
C and D are correct
upvoted 2 times
AVB22
2 years, 8 months ago
I confirm, it compiles with both c and d but we cannot see the body of d
upvoted 1 times
...
...
Ritesh_
4 years, 9 months ago
Correct.Answer is C.
upvoted 4 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