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
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.
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.
d7bb0b2
1 day, 14 hours ago[Removed]
3 months, 2 weeks agoStavok
4 months, 3 weeks agoObalt
10 months, 1 week ago