exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 92 discussion

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

Given the code fragment:



Which statement prints the same value of result? (Choose two.)

  • A. System.out.printIn(IntStream.range(0, 99).count());
  • B. System.out.printIn(IntStream.rangeClosed(1, 100).count());
  • C. System.out.printIn(IntStream.range(1, 100).count());
  • D. System.out.printIn(IntStream.rangeClosed(0, 100).map(x -> x).count());
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
d7bb0b2
1 day, 14 hours ago
ONLY B is correct (D is 101 causa counting 0 to 100 boths included)
upvoted 1 times
...
[Removed]
3 months, 2 weeks ago
Selected Answer: B
There must be a typo in the answers since only 1 results in 100. Which is B A: System.out.println(IntStream.range(0, 99).count()); --> 99 B: System.out.println(IntStream.rangeClosed(1, 100).count()); --> 100 C: System.out.println(IntStream.range(1, 100).count()); --> 99 D: System.out.println(IntStream.rangeClosed(0, 100).map(x -> x).count()); --> 101
upvoted 4 times
...
Stavok
4 months, 3 weeks ago
Selected Answer: BD
The code fragment generates an IntStream using the generate() method with a Supplier that always returns the value of z1, which is 1. The stream is then limited to 100 elements using the limit() method and the sum of all elements is calculated using the sum() method. The result is the sum of 100 ones, which is 100. Both statements generate an IntStream with 100 elements and then count the number of elements in the stream using the count() method. The result of both statements is 100, which is the same as the value of result.
upvoted 1 times
...
Obalt
10 months, 1 week ago
B is the correct answer
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