Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 145

Given:

and the code fragment:

What is the result?

    Correct Answer: B

    The code first creates a list of Person objects with the specified names and salaries. It then creates a stream from the list and filters the stream to include only those Person objects whose first name starts with 'J'. This results in two Person objects: 'John' with a salary of 2000 and 'Joe' with a salary of 1000. The mapToInt(Person::getSalary) method converts the salaries into an IntStream with values 2000 and 1000. The average() method calculates the average of these salaries, which is 1500.0. Therefore, the correct result is 1500.0.

Discussion
jduarteOption: B

answer B. Tested

DarGrinOption: B

Answer is B. mapToInt() returns an IntStream. average() returns an OptionalDouble. getAsDouble() returns an double

steefaandOption: B

B is true.