Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need some help with these, i have guessed at some but wanna make sure my answers are right. Thank you Terminal Stream operation ________ performs

Need some help with these, i have guessed at some but wanna make sure my answers are right. Thank you

Terminal Stream operation ________ performs processing on every element in a stream (e.g., display each element).

forNext

for

forAll

forEach

QUESTION 2

Prior to Java SE 8, Java supported three programming paradigms. Java SE 8 adds ________.

procedural programming

object-oriented programming

generic programming

functional programming.

QUESTION 3

A nice performance feature of lazy evaluation is the ability to perform________ evaluation, that is, to stop processing the stream pipeline as soon as the desired result is available.

premature

short circuit

terminal

intermediate

QUESTION 4

What is the meaning of ( ) in the following lambda? () -> System.out.println("Welcome to lambdas!")

the lambdas parameters are inferred

the lambdas parameters are supplied by a method reference

the lambda has an empty parameter list

the given expression is not a valid lambda

QUESTION 5

The basic generic functional interface ________ in package java.util.function contains method apply that takes a T argument and returns a value of type R. Calls a method on the T argument and returns that methods result.

Consumer

Function

Supplier

BinaryOperator

QUESTION 6

________ is an intermediate operation that transforms a streams elements to new values and produces a stream containing the resulting (possibly different type) elements.

Transforming

Converting

Mapping

Translating

QUESTION 7

Class Arrays provides ________ stream methods for creating IntStreams, LongStreams and DoubleStreams from int, long and double arrays or from ranges of elements in the arrays.

virtual

package

overridden

overloaded

QUESTION 8

Collectors static method groupingBy with two arguments receives a Function that classifies the objects in the stream and another Collector (known as the ________ Collector).

stream

downstream

grouping stream

upsteam

QUESTION 9

Interface Stream (package java.util.stream) is a generic interface for performing stream operations on objects. The types of objects that are processed are determined by the Streams ________.

root

origin

source

start

QUESTION 10

A lambda expression represents a(n) ________ methoda shorthand notation for implementing a functional interface.

functional

unnamed

undesignated

anonymous

QUESTION 11

Method reduces first argument is formally called a(n) ________ valuea value that, when combined with any stream element using the IntBinaryOperator produces that elements original value.

original

identity

preserve

self

QUESTION 12

Class IntStream provides terminal operations for common stream ________ count returns the number of elements, min returns the smallest int, max returns the largest int, sum returns the sum of all the ints and average returns an OptionalDouble (package java.util) containing the average of the ints as a value of type double.

consolidations

deductions

reductions

trims

QUESTION 13

The basic generic functional interface ________ in package java.util.function contains method test that takes a T argument and returns a boolean. Tests whether the T argument satisfies a condition.

Consumer

Function

Supplier

Predicate

QUESTION 14

Stream method ________ maps objects to double values and returns a DoubleStream. The method receives an object that implements the functional interface ToDoubleFunction (package java.util.function).

doubleMap

toDouble

mapToDouble

toDoubleStream

QUESTION 15

Collectors static method groupingBy with one argument receives a Function that classifies objects in the streamthe values returned by this function are used as the keys in a Map. The corresponding values, by default, are ________ containing the stream elements in a given category.

Lists

Arrays

Strings

Collectors

QUESTION 16

Functional interface BiConsumers accept method has two parameters. For Maps, the first represents the ________ and the second the corresponding ________.

key, variable

lambda, value

lambda, variable

key, value

QUESTION 17

Class Arrays ________ method is used to create a Stream from an array of objects.

stream

arrayToStream

createStream

objectToStream

QUESTION 18

An ________ (package java.util.stream) is a specialized stream for manipulating int values.

StreamOfInt

IStream.

IntegerStream

IntStream

QUESTION 19

The basic generic functional interface ________ in package java.util.function contains method get that takes no arguments and produces a value of type T. Often used to create a collection object in which a stream operations results are placed.

Consumer

Function

Supplier

BinaryOperator

QUESTION 20

The basic generic functional interface ________ in package java.util.function contains method accept that takes a T argument and returns void. Performs a task with its T argument, such as outputting the object, invoking a method of the object, etc.

Consumer

Function

Supplier

BinaryOperator

QUESTION 21

The basic generic functional interface ________ in package java.util.function contains method apply that takes two T arguments, performs an operation on them (such as a calculation) and returns a value of type T.

Consumer

Function

Supplier

BinaryOperator

QUESTION 22

By default, method sorted uses ________.

ascending order

the natural order for the stream's element type

descending order

the order specified in a command-line argument

QUESTION 23

Map method entrySet returns a Set of Map.Entry objects containing the Maps ________.

values

keys

index

keyvalue pairs

QUESTION 24

The new language and library capabilities that support functional programming were added to Java as part of Project ________.

Utilitarian

Upsilon

Lambda

Utility

QUESTION 25

Functional interface Comparators default method ________ reverses an existing Comparators ordering.

invert

descending

reversed

downward

QUESTION 26

Map method ________ performs an operation on each keyvalue pair.

for

forNext

forEach

forAll

QUESTION 27

Stream mutable reduction operation ________ creates a new collection of elements containing the results of the streams prior operations.

combine

accumulate

gather

collect

QUESTION 28

________ is a method reference for an instance method that should be called on a specific object. It creates a one-parameter lambda that invokes the instance method on the specified objectpassing the lambdas argument to the instance methodand returns the methods result.

Math::sqrt

System.out::println

TreeMap::new

String::toUpperCase

QUESTION 29

Stream method ________ eliminates duplicate objects in a stream.

distinct

discrete

unique

different

QUESTION 30

Intermediate Stream operation ________ results in a stream in which each element of the original stream is mapped to a new value (possibly of a different type)e.g., mapping numeric values to the squares of the numeric values. The new stream has the same number of elements as the original stream.

mapped

map

mapper

mapping

QUESTION 31

Collectors static method ________ returns a Collector that counts the number of objects in a given classification, rather than collecting them into a List.

counter

count

counting

enumerate

QUESTION 32

Stream mutable reduction operation ________creates an array containing the results of the streams prior operations.

array

createArray

toArray

reduceArray

QUESTION 33

The intermediate Stream operation ________ results in a stream containing only the unique elements.

distinct

map

filter

limit

QUESTION 34

________ is a method reference for an instance method of a class. It creates a one-parameter lambda that invokes the instance method on the lambdas argument and returns the methods result.

Math::sqrt

System.out::println

TreeMap::new

String::toUpperCase

QUESTION 35

________ is a constructor reference. It creates a lambda that invokes the no-argument constructor of the specified class to create and initialize a new object of that class.

Math::sqrt

System.out::println

TreeMap::new

String::toUpperCase

QUESTION 36

You can define your own reductions for an IntStream by calling its ________ method. The first argument is a value that helps you begin the reduction operation and the second argument is an object that implements the IntBinaryOperator functional interface.

reduction.

lessen

trim

reduce

QUESTION 37

You can declare that an interface is a functional interface by preceding it with the @FunctionalInterface annotation. The compiler will then ensure that the interface contains ________; otherwise, itll generate a compilation error.

no abstract methods

all abstract methods

only one abstract method

one or more abstract methods.

QUESTION 38

The basic generic functional interface ________ in package java.util.function contains method get that takes no arguments and returns a value of type T.

UnaryOperator

Function

Supplier

BinaryOperator

QUESTION 39

Intermediate Stream operation ________ results in a stream with the specified number of elements from the beginning of the original stream.

distinct

map

filter

limit

QUESTION 40

IntStream method ________performs the count, min, max, sum and average operations in one pass of an IntStreams elements and returns the results as an IntSummaryStatistics object (package java.util).

allStatistics.

completeStatistics.

entireStatistics.

summaryStatistics

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions