1z0-809: Java SE 8 Programmer II Fragment Practice Questions
The free 1z0-809: Java SE 8 Programmer II questions that deal with fragment, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #3
Given the code fragment: Which code fragment, when inserted at line 7, enables printing 100?

Correct answer: C
Explanation
ToIntFunction<Integer> with applyAsInt is the only fragment that compiles; it unboxes the argument, adds ten and returns the int 100. Option A fails because Function requires two type arguments, and the raw IntFunction and ToIntFunction options call wrong methods.
Question #7
Given the code fragment: Path p1 = Paths.get(“/Pics/MyPic.jpeg”); System.out.println (p1.getNameCount() + “:” + p1.getName(1) + “:” + p1.getFileName()); Assume that the Pics directory does NOT exist. What is the result?
Correct answer: B
Explanation
The path has two name elements, Pics and MyPic.jpeg, so getNameCount() is 2, getName(1) is MyPic.jpeg and getFileName() is MyPic.jpeg. Path operations are purely syntactic, so the missing directory causes no exception.
Question #8
Given the code fragment: Which code fragment, when inserted at line n1, ensures false is printed?

Correct answer: D
Explanation
allMatch returns false because "Java EE" and "Java ME" do not equal "Java". findFirst() and findAny() on this sequential stream return "Java", and anyMatch returns true, so A, B and C print true.
Question #10
Given the code fragment: What is the result?

Correct answer: B
Explanation
count() returns a long, which is autoboxed to Long, so the code compiles. The filter removes the two empty strings, leaving George, John and Jim, so 3 is printed.
Continue with 1z0-809: Java SE 8 Programmer II
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in 1z0-809: Java SE 8 Programmer II, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
