17.2.2 Q4: Which of the following statements is false?
a. A lambda that receives two ints, x and y, and returns their sum is
(int x, int y) -> {return x + y;}
b. A lambda’s parameter types may be omitted, as in:
(x, y) -> {return x + y;}
in which case, the parameter and return types are set to the lambda’s default type.
c. A lambda with a one-expression body can be written as:
(x, y) -> x + y
In this case, the expression’s value is implicitly returned.
d. When a lambda’s parameter list contains only one parameter, the parentheses may be
omitted, as in:
value -> System.out.printf(“%d “, value)
17.2.2 Q5: What is the meaning of ( ) in the following lambda?
() -> System.out.println(“Welcome to lambdas!”)
a. the lambdas parameters are inferred
b. the lambdas parameters are supplied by a method reference
c. the lambda has an empty parameter list
d. the given expression is not a valid lambda
17.2.3 Streams
17.2.3 Q1: Which of the following statements is false?
a. Streams are objects that implement interface Stream (from the package
java.util.stream) and enable you to perform functional programming tasks.
b. Streams move elements through a sequence of processing steps—known as a stream
pipeline—that begins with a data source, performs various intermediate operations on the
data source’s elements and ends with a terminal operation.
c. A stream pipeline is formed by chaining method calls.
d. An advantage of streams over collections is that streams have their own storage, so
once a stream is processed, it can be reused, because it maintains a copy of the original
data source.