Java Exam CH. 17 UPDATED ACTUAL Exam Questions and
CORRECT Answers
Which of the following statements is false?
a. Functional interfaces are also known as single abstract method (SAM) interfaces.
b. Package java.util.function contains six basic functional interfaces BinaryOperator, Consumer,
Function, Predicate, Supplier and UnaryOperator.
c. There are many specialized versions of the six basic functional interfaces for use with int, long
and double primitive values. There are also generic customizations of Consumer, Function and
Predicate for binary operations—that is, methods that take two arguments.
d. All of these statements are true - All of these statements are true
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - d. BinaryOperator<T>
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - a. Consumer<T>
,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 method's result.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - b. Function<T,R>
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. Predicate<T> - d. Predicate<T>
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 operation's results are placed.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - c. Supplier<T>
The basic generic functional interface ________ in package java.util.function contains method
get that takes no arguments and returns a value of type T.
a. UnaryOperator<T>
b. Function<T,R>
c. Supplier<T>
, d. BinaryOperator<T> - a. UnaryOperator<T>
A lambda expression represents a(n) ________ method—a shorthand notation for implementing
a functional interface.
a. functional
b. unnamed
c. undesignated
d. anonymous - d. anonymous
The type of a lambda is the type of the ________ that the lambda implements.
a. anonymous class
b. functional interface
c. stream
d. collection - b. functional interface
Which of the following statements is false?
a. Lambda expressions can be used anywhere functional interfaces are expected.
b. A lambda consists of a parameter list followed by the arrow token and a body, as in:
[parameterList] -> {statements}
c.Method references are specialized shorthand forms of lambdas.
d. Each of the above statements is true - b. A lambda consists of a parameter list followed by the
arrow token and a body, as in:
[parameterList] -> {statements}
Actually, a lambda consists of a parameter list followed by the arrow token and a body, as in:
(parameterList) -> {statements}
Which of the following statements is false?
a. A lambda that receives two ints, x and y, and returns their sum is
CORRECT Answers
Which of the following statements is false?
a. Functional interfaces are also known as single abstract method (SAM) interfaces.
b. Package java.util.function contains six basic functional interfaces BinaryOperator, Consumer,
Function, Predicate, Supplier and UnaryOperator.
c. There are many specialized versions of the six basic functional interfaces for use with int, long
and double primitive values. There are also generic customizations of Consumer, Function and
Predicate for binary operations—that is, methods that take two arguments.
d. All of these statements are true - All of these statements are true
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - d. BinaryOperator<T>
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - a. Consumer<T>
,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 method's result.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - b. Function<T,R>
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.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. Predicate<T> - d. Predicate<T>
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 operation's results are placed.
a. Consumer<T>
b. Function<T,R>
c. Supplier<T>
d. BinaryOperator<T> - c. Supplier<T>
The basic generic functional interface ________ in package java.util.function contains method
get that takes no arguments and returns a value of type T.
a. UnaryOperator<T>
b. Function<T,R>
c. Supplier<T>
, d. BinaryOperator<T> - a. UnaryOperator<T>
A lambda expression represents a(n) ________ method—a shorthand notation for implementing
a functional interface.
a. functional
b. unnamed
c. undesignated
d. anonymous - d. anonymous
The type of a lambda is the type of the ________ that the lambda implements.
a. anonymous class
b. functional interface
c. stream
d. collection - b. functional interface
Which of the following statements is false?
a. Lambda expressions can be used anywhere functional interfaces are expected.
b. A lambda consists of a parameter list followed by the arrow token and a body, as in:
[parameterList] -> {statements}
c.Method references are specialized shorthand forms of lambdas.
d. Each of the above statements is true - b. A lambda consists of a parameter list followed by the
arrow token and a body, as in:
[parameterList] -> {statements}
Actually, a lambda consists of a parameter list followed by the arrow token and a body, as in:
(parameterList) -> {statements}
Which of the following statements is false?
a. A lambda that receives two ints, x and y, and returns their sum is