Deck 17: Lambdas and Streams

ملء الشاشة (f)
exit full mode
سؤال
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.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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>
سؤال
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.

A) consolidations
B) deductions
C) reductions
D) trims
سؤال
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.

A) reduction.
B) lessen
C) trim
D) reduce
سؤال
Which of the following statements is false?

A) A method reference of the form objectName::instanceMethodName is a bound instance method reference.
B) A method reference of the form ClassName::staticMethodName is a static method reference.
C) Collectors method joining is a collector that creates a concatenated String representation of the stream's elements, appending each element to the String separated from the previous element by the joining method's argument.
D) All of the above statements are true.
سؤال
Which of the following statements is false?

A) Each intermediate operation results in a new stream.
B) Each new stream is simply an object representing the processing steps that have been specified to that point in the pipeline.
C) Chaining intermediate-operation method calls adds to the set of processing steps to perform on each stream element. The last stream object in the stream pipeline contains all the processing steps to perform on each stream element.
D) When you initiate a stream pipeline with a terminal operation, the each processing step is applied for to all the stream elements before the next processing step is applied.
سؤال
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>
سؤال
IntStream method ________ (a terminal operation) performs a task on each stream element.

A) for
B) forEach
C) forElement
D) None of the above.
سؤال
An________ (package java.util.stream) is a stream that manipulates int values.

A) StreamOfInt
B) IStream.
C) IntegerStream
D) IntStream
سؤال
IntStream method ________ performs the count, min, max, sum and average operations in one pass of an IntStream's elements and returns the results as an IntSummaryStatistics object (package java.util).

A) allStatistics.
B) completeStatistics.
C) entireStatistics.
D) summaryStatistics
سؤال
Which of the following statements is false?

A) With external iteration you specify all the iteration details.
B) Every time you write code that modifies a variable, it's possible to introduce an error into your code.
C) Letting the library determine how to iterate over a collection of elements is known as internal iteration.
D) All of the above are true.
سؤال
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>
سؤال
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>
سؤال
________ is an intermediate operation that transforms a stream's elements to new values and produces a stream containing the resulting (possibly different type) elements.

A) Transforming
B) Converting
C) Mapping
D) Translating
سؤال
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>
سؤال
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>
سؤال
Method reduce's first argument is formally called a(n) ________ value-a value that, when combined with any stream element using the IntBinaryOperator produces that element's original value.

A) original
B) identity
C) preserve
D) self
سؤال
Which of the following statements is false?

A) You filter elements to produce a stream of intermediate results that match a predicate.
B) IntStream method filter receives an object that method that takes one parameter and returns a boolean result.
C) If the result of calling filter's argument is true for a given element, that element is included in the resulting stream.
D) All of the above statements are true.
سؤال
Prior to Java SE 8, Java supported three programming paradigms. Java SE 8 added ________.

A) procedural programming
B) object-oriented programming
C) generic programming
D) functional programming.
سؤال
Which of the following statements is false?

A) IntStream methods range and rangeClosed each produce an ordered sequence of int values.
B) IntStream methods range and rangeClosed take two int arguments representing the range of values.
C) Method range produces a sequence of values from its first argument up to its second argument.
D) Method rangeClosed produces a sequence of values including both of its arguments.
سؤال
Stream method ________ eliminates duplicate objects in a stream.

A) distinct
B) discrete
C) unique
D) different
سؤال
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 Stream's ________.

A) root
B) origin
C) source
D) start
سؤال
Functional interface Comparator's default method ________ reverses an existing Comparator's ordering.

A) invert
B) descending
C) reversed
D) downward
سؤال
Class Array's ________ method is used to create a Stream from an array of objects.

A) stream
B) arrayToStream
C) createStream
D) objectToStream
سؤال
________ is a method reference for an instance method of a class. It creates a one-parameter lambda that invokes the instance method on the lambda's argument and returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
سؤال
________ 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 object-passing the lambda's argument to the instance method-and returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
سؤال
________ is s method reference for a static method of a class. It creates a one-parameter lambda in which the lambda's argument is passed to the specified a static method and the lambda returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
سؤال
Which of the following statements is true?

A) Stream method filter receives a Predicate and results in a stream of objects that match the Predicate.
B) Predicate method test returns a boolean indicating whether the argument satisfies a condition.
C) Interface Predicate also has methods and, negate and or.
D) Each of these statements is true.
سؤال
________ 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.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
سؤال
Map method ________ performs an operation on each key-value pair.

A) for
B) forNext
C) forEach
D) forAll
سؤال
Which of the following statements is false?

A) Stream method map maps each element to a new value and produces a new stream with the same number of elements as the original stream.
B) A reference is a shorthand notation for a lambda expression.
C) ClassName::instanceMethodName represents a method reference for an instance method of a class. Creates a one-parameter lambda that invokes the instance method on the lambda's argument and returns the method's result.
D) ClassName::new represents a constructor reference. Creates a lambda that invokes the no-argument constructor of the specified class to create and initialize a new object of that class.
سؤال
Which of the following statements is false?

A) Stream method sort orders a stream's elements into ascending order by default. Actually, Stream method sorted orders a stream's elements into ascending order by default.
B) To create a collection containing a stream pipeline's results, you can use Stream method collect (a terminal operation). As the stream pipeline is processed, method collect performs a mutable reduction operation that places the results into an object, such as a List, Map or Set.
C) Method collect with one argument receives an object that implements interface Collector (package java.util.stream), which specifies how to perform a mutable reduction.
D) Class Collectors (package java.util.stream) provides static methods that return predefined Collector implementations.
سؤال
Which statement in the following sequence of statements about sorting objects by two fields is false?

A) To sort objects by two fields, you create a Comparator that uses two Functions.
B) First you call Comparator method comparing to create a Comparator with the first Function.
C) On the Comparator for the first field, you call method comparing with the second Function.
D) The resulting Comparator compares objects using the first Function then, for objects that are equal, compares them by the second Function.
سؤال
By default, method sorted uses ________.

A) ascending order
B) the natural order for the stream's element type
C) descending order
D) the order specified in a command-line argument
سؤال
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.

A) premature
B) short circuit
C) terminal
D) intermediate
سؤال
Collectors static method groupingBy with one argument receives a Function that classifies objects in the stream-the 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.

A) Lists
B) Arrays
C) Strings
D) Collectors
سؤال
Which of the following statements is false?

A) The parameter names and variable names that you use in lambdas cannot be the same as any other local variables in the lambda's lexical scope; otherwise, a compilation error occurs.
B) Lambdas may use only final local variables.
C) A lambda that refers to a local variable in the enclosing lexical scope is known as a capturing lambda.
D) All of the above statements are true.
سؤال
Stream method findFirst is a short-circuiting terminal operation that processes the stream pipeline and terminates processing as soon as the first object from the stream pipeline is found. The method returns a(n) ________ containing the object that was found, if any.

A) Optional
B) Discretionary
C) Elective
D) Extra
سؤال
Functional interface BiConsumer's accept method has two parameters. For Maps, the first represents the ________ and the second the corresponding ________.

A) key, variable
B) lambda, value
C) lambda, variable
D) key, value
سؤال
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.

A) virtual
B) package
C) overridden
D) overloaded
سؤال
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, it'll generate a compilation error.

A) no abstract methods
B) all abstract methods
C) only one abstract method
D) one or more abstract methods.
سؤال
Collectors static method ________ returns a Collector that counts the number of objects in a given classification, rather than collecting them into a List.

A) counter
B) count
C) counting
D) enumerate
سؤال
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)
سؤال
Which of the following statements is false?

A) Class SecureRandom's methods ints, longs and doubles (inherited from class Random) return IntStream, LongStream and DoubleStream, respectively, for streams of random numbers.
B) SecureRandom method ints with no arguments creates an IntStream for an infinite stream of random int values.
C) An infinite stream is a stream with an unknown number of elements-you use an intermediate operation to complete processing on an infinite stream.
D) SecureRandom method ints with a long argument creates an IntStream with the specified number of random int values.
سؤال
Collectors static method groupingBy with two arguments receives a Function that classifies the objects in the stream and another Collector (known as the ________ Collector).

A) stream
B) downstream
C) grouping stream
D) upsteam
سؤال
Map method entrySet returns a Set of Map.Entry objects containing the Map's ________.

A) values
B) keys
C) index
D) key-value pairs
سؤال
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.
سؤال
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.
سؤال
The intermediate Stream operation ________ results in a stream containing only the elements that satisfy a condition.

A) distinct
B) map
C) filter
D) limit
سؤال
Terminal operations are ________; they perform the requested operation when they are called.

A) immediate
B) idle
C) lazy
D) eager
سؤال
Intermediate operations are________; they aren't performed until a terminal operation is invoked. This allows library developers to optimize stream-processing performance.

A) eager
B) idle
C) lazy
D) inactive
سؤال
Which of the following statements is false?

A) Functional interfaces must contain only one method and that method must be abstract.
B) When a class implements an interface with default methods and does not override them, the class inherits the default methods' implementations. An interface's designer can now evolve an interface by adding new default and static methods without breaking existing code that implements the interface.
C) If one class inherits the same default method from two interfaces, the class must override that method; otherwise, the compiler will generate a compilation error.
D) You can create your own functional interfaces by ensuring that each contains only one abstract method and zero or more default or static methods.
سؤال
Which of the following statements is false?

A) Some event-listener interfaces are functional interfaces.
B) For such interfaces as mentioned in (a), you can implement event handlers with lambdas.
C) For a simple event handler, a lambda significantly reduces the amount of code you need to write.
D) All of the above are true.
سؤال
Which of the following statements is false?

A) Files method lines creates a String containing the lines of text from a file.
B) Stream method flatMap receives a Function that maps an object into a stream-e.g., a line of text into words.
C) Pattern method splitAsStream uses a regular expression to tokenize a String.
D) Collectors method groupingBy with three arguments receives a classifier, a Map factory and a downstream Collector.
سؤال
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).

A) doubleMap
B) toDouble
C) mapToDouble
D) toDoubleStream
سؤال
Which of the following statements is false?

A) Interface IntPredicate's default method and performs a logical AND operation with short-circuit evaluation between the IntPredicate on which it's called and its IntPredicate argument.
B) Interface IntPredicate's default method invert reverses the boolean value of the IntPredicate on which it's called.
C) Interface IntPredicate default method or performs a logical OR operation with short-circuit evaluation between the IntPredicate on which it's called and its IntPredicate argument.
D) You can use the interface IntPredicate default methods to compose more complex conditions.
سؤال
Which of the following statements is false?

A) SecureRandom method ints with two int arguments creates an IntStream for an infinite stream of random int values in the range starting with the first argument and up to, but not including, the second.
B) SecureRandom method ints with a long and two int arguments creates an IntStream with the specified number of random int values in the range starting with the first argument and up to, but not including, the second.
C) To convert an IntStream to a Stream call IntStream method toStream.
D) Function static method identity creates a Function that simply returns its argument.
سؤال
A lambda expression represents a(n) ________ method-a shorthand notation for implementing a functional interface.

A) functional
B) unnamed
C) undesignated
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
سؤال
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
سؤال
Stream mutable reduction operation ________ creates a new collection of elements containing the results of the stream's prior operations.

A) combine
B) accumulate
C) gather
D) collect
سؤال
The intermediate Stream operation ________ results in a stream containing only the unique elements.

A) distinct
B) map
C) filter
D) limit
سؤال
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.

A) mapped
B) map
C) mapper
D) mapping
سؤال
Terminal Stream operation ________ performs processing on every element in a stream (e.g., display each element).

A) forNext
B) for
C) forAll
D) forEach
سؤال
Stream mutable reduction operation ________creates an array containing the results of the stream's prior operations.

A) array
B) createArray
C) toArray
D) reduceArray
سؤال
Intermediate Stream operation ________ results in a stream with the specified number of elements from the beginning of the original stream.

A) distinct
B) map
C) filter
D) limit
سؤال
Stream reduction operation ________ uses the elements of a collection to produce a single value using an associative accumulation function (e.g., a lambda that adds two elements).

A) reduce
B) condense
C) combine
D) associate
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/67
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 17: Lambdas and Streams
1
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.
D
2
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>
UnaryOperator<T>
3
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.

A) consolidations
B) deductions
C) reductions
D) trims
C
4
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.

A) reduction.
B) lessen
C) trim
D) reduce
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following statements is false?

A) A method reference of the form objectName::instanceMethodName is a bound instance method reference.
B) A method reference of the form ClassName::staticMethodName is a static method reference.
C) Collectors method joining is a collector that creates a concatenated String representation of the stream's elements, appending each element to the String separated from the previous element by the joining method's argument.
D) All of the above statements are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following statements is false?

A) Each intermediate operation results in a new stream.
B) Each new stream is simply an object representing the processing steps that have been specified to that point in the pipeline.
C) Chaining intermediate-operation method calls adds to the set of processing steps to perform on each stream element. The last stream object in the stream pipeline contains all the processing steps to perform on each stream element.
D) When you initiate a stream pipeline with a terminal operation, the each processing step is applied for to all the stream elements before the next processing step is applied.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
7
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>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
8
IntStream method ________ (a terminal operation) performs a task on each stream element.

A) for
B) forEach
C) forElement
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
9
An________ (package java.util.stream) is a stream that manipulates int values.

A) StreamOfInt
B) IStream.
C) IntegerStream
D) IntStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
10
IntStream method ________ performs the count, min, max, sum and average operations in one pass of an IntStream's elements and returns the results as an IntSummaryStatistics object (package java.util).

A) allStatistics.
B) completeStatistics.
C) entireStatistics.
D) summaryStatistics
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following statements is false?

A) With external iteration you specify all the iteration details.
B) Every time you write code that modifies a variable, it's possible to introduce an error into your code.
C) Letting the library determine how to iterate over a collection of elements is known as internal iteration.
D) All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
12
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>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
13
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>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
14
________ is an intermediate operation that transforms a stream's elements to new values and produces a stream containing the resulting (possibly different type) elements.

A) Transforming
B) Converting
C) Mapping
D) Translating
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
15
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>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
16
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>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
17
Method reduce's first argument is formally called a(n) ________ value-a value that, when combined with any stream element using the IntBinaryOperator produces that element's original value.

A) original
B) identity
C) preserve
D) self
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following statements is false?

A) You filter elements to produce a stream of intermediate results that match a predicate.
B) IntStream method filter receives an object that method that takes one parameter and returns a boolean result.
C) If the result of calling filter's argument is true for a given element, that element is included in the resulting stream.
D) All of the above statements are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
19
Prior to Java SE 8, Java supported three programming paradigms. Java SE 8 added ________.

A) procedural programming
B) object-oriented programming
C) generic programming
D) functional programming.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which of the following statements is false?

A) IntStream methods range and rangeClosed each produce an ordered sequence of int values.
B) IntStream methods range and rangeClosed take two int arguments representing the range of values.
C) Method range produces a sequence of values from its first argument up to its second argument.
D) Method rangeClosed produces a sequence of values including both of its arguments.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
21
Stream method ________ eliminates duplicate objects in a stream.

A) distinct
B) discrete
C) unique
D) different
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
22
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 Stream's ________.

A) root
B) origin
C) source
D) start
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
23
Functional interface Comparator's default method ________ reverses an existing Comparator's ordering.

A) invert
B) descending
C) reversed
D) downward
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
24
Class Array's ________ method is used to create a Stream from an array of objects.

A) stream
B) arrayToStream
C) createStream
D) objectToStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
25
________ is a method reference for an instance method of a class. It creates a one-parameter lambda that invokes the instance method on the lambda's argument and returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
26
________ 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 object-passing the lambda's argument to the instance method-and returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
27
________ is s method reference for a static method of a class. It creates a one-parameter lambda in which the lambda's argument is passed to the specified a static method and the lambda returns the method's result.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following statements is true?

A) Stream method filter receives a Predicate and results in a stream of objects that match the Predicate.
B) Predicate method test returns a boolean indicating whether the argument satisfies a condition.
C) Interface Predicate also has methods and, negate and or.
D) Each of these statements is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
29
________ 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.

A) Math::sqrt
B) System.out::println
C) TreeMap::new
D) String::toUpperCase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
30
Map method ________ performs an operation on each key-value pair.

A) for
B) forNext
C) forEach
D) forAll
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which of the following statements is false?

A) Stream method map maps each element to a new value and produces a new stream with the same number of elements as the original stream.
B) A reference is a shorthand notation for a lambda expression.
C) ClassName::instanceMethodName represents a method reference for an instance method of a class. Creates a one-parameter lambda that invokes the instance method on the lambda's argument and returns the method's result.
D) ClassName::new represents a constructor reference. Creates a lambda that invokes the no-argument constructor of the specified class to create and initialize a new object of that class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which of the following statements is false?

A) Stream method sort orders a stream's elements into ascending order by default. Actually, Stream method sorted orders a stream's elements into ascending order by default.
B) To create a collection containing a stream pipeline's results, you can use Stream method collect (a terminal operation). As the stream pipeline is processed, method collect performs a mutable reduction operation that places the results into an object, such as a List, Map or Set.
C) Method collect with one argument receives an object that implements interface Collector (package java.util.stream), which specifies how to perform a mutable reduction.
D) Class Collectors (package java.util.stream) provides static methods that return predefined Collector implementations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which statement in the following sequence of statements about sorting objects by two fields is false?

A) To sort objects by two fields, you create a Comparator that uses two Functions.
B) First you call Comparator method comparing to create a Comparator with the first Function.
C) On the Comparator for the first field, you call method comparing with the second Function.
D) The resulting Comparator compares objects using the first Function then, for objects that are equal, compares them by the second Function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
34
By default, method sorted uses ________.

A) ascending order
B) the natural order for the stream's element type
C) descending order
D) the order specified in a command-line argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
35
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.

A) premature
B) short circuit
C) terminal
D) intermediate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
36
Collectors static method groupingBy with one argument receives a Function that classifies objects in the stream-the 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.

A) Lists
B) Arrays
C) Strings
D) Collectors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following statements is false?

A) The parameter names and variable names that you use in lambdas cannot be the same as any other local variables in the lambda's lexical scope; otherwise, a compilation error occurs.
B) Lambdas may use only final local variables.
C) A lambda that refers to a local variable in the enclosing lexical scope is known as a capturing lambda.
D) All of the above statements are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
38
Stream method findFirst is a short-circuiting terminal operation that processes the stream pipeline and terminates processing as soon as the first object from the stream pipeline is found. The method returns a(n) ________ containing the object that was found, if any.

A) Optional
B) Discretionary
C) Elective
D) Extra
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
39
Functional interface BiConsumer's accept method has two parameters. For Maps, the first represents the ________ and the second the corresponding ________.

A) key, variable
B) lambda, value
C) lambda, variable
D) key, value
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
40
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.

A) virtual
B) package
C) overridden
D) overloaded
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
41
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, it'll generate a compilation error.

A) no abstract methods
B) all abstract methods
C) only one abstract method
D) one or more abstract methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
42
Collectors static method ________ returns a Collector that counts the number of objects in a given classification, rather than collecting them into a List.

A) counter
B) count
C) counting
D) enumerate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
43
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which of the following statements is false?

A) Class SecureRandom's methods ints, longs and doubles (inherited from class Random) return IntStream, LongStream and DoubleStream, respectively, for streams of random numbers.
B) SecureRandom method ints with no arguments creates an IntStream for an infinite stream of random int values.
C) An infinite stream is a stream with an unknown number of elements-you use an intermediate operation to complete processing on an infinite stream.
D) SecureRandom method ints with a long argument creates an IntStream with the specified number of random int values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
45
Collectors static method groupingBy with two arguments receives a Function that classifies the objects in the stream and another Collector (known as the ________ Collector).

A) stream
B) downstream
C) grouping stream
D) upsteam
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
46
Map method entrySet returns a Set of Map.Entry objects containing the Map's ________.

A) values
B) keys
C) index
D) key-value pairs
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
47
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
48
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
49
The intermediate Stream operation ________ results in a stream containing only the elements that satisfy a condition.

A) distinct
B) map
C) filter
D) limit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
50
Terminal operations are ________; they perform the requested operation when they are called.

A) immediate
B) idle
C) lazy
D) eager
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
51
Intermediate operations are________; they aren't performed until a terminal operation is invoked. This allows library developers to optimize stream-processing performance.

A) eager
B) idle
C) lazy
D) inactive
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
52
Which of the following statements is false?

A) Functional interfaces must contain only one method and that method must be abstract.
B) When a class implements an interface with default methods and does not override them, the class inherits the default methods' implementations. An interface's designer can now evolve an interface by adding new default and static methods without breaking existing code that implements the interface.
C) If one class inherits the same default method from two interfaces, the class must override that method; otherwise, the compiler will generate a compilation error.
D) You can create your own functional interfaces by ensuring that each contains only one abstract method and zero or more default or static methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
53
Which of the following statements is false?

A) Some event-listener interfaces are functional interfaces.
B) For such interfaces as mentioned in (a), you can implement event handlers with lambdas.
C) For a simple event handler, a lambda significantly reduces the amount of code you need to write.
D) All of the above are true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
54
Which of the following statements is false?

A) Files method lines creates a String containing the lines of text from a file.
B) Stream method flatMap receives a Function that maps an object into a stream-e.g., a line of text into words.
C) Pattern method splitAsStream uses a regular expression to tokenize a String.
D) Collectors method groupingBy with three arguments receives a classifier, a Map factory and a downstream Collector.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
55
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).

A) doubleMap
B) toDouble
C) mapToDouble
D) toDoubleStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
56
Which of the following statements is false?

A) Interface IntPredicate's default method and performs a logical AND operation with short-circuit evaluation between the IntPredicate on which it's called and its IntPredicate argument.
B) Interface IntPredicate's default method invert reverses the boolean value of the IntPredicate on which it's called.
C) Interface IntPredicate default method or performs a logical OR operation with short-circuit evaluation between the IntPredicate on which it's called and its IntPredicate argument.
D) You can use the interface IntPredicate default methods to compose more complex conditions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which of the following statements is false?

A) SecureRandom method ints with two int arguments creates an IntStream for an infinite stream of random int values in the range starting with the first argument and up to, but not including, the second.
B) SecureRandom method ints with a long and two int arguments creates an IntStream with the specified number of random int values in the range starting with the first argument and up to, but not including, the second.
C) To convert an IntStream to a Stream call IntStream method toStream.
D) Function static method identity creates a Function that simply returns its argument.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
58
A lambda expression represents a(n) ________ method-a shorthand notation for implementing a functional interface.

A) functional
B) unnamed
C) undesignated
D) anonymous
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
59
The type of a lambda is the type of the ________ that the lambda implements.

A) anonymous class
B) functional interface
C) stream
D) collection
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
60
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
61
Stream mutable reduction operation ________ creates a new collection of elements containing the results of the stream's prior operations.

A) combine
B) accumulate
C) gather
D) collect
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
62
The intermediate Stream operation ________ results in a stream containing only the unique elements.

A) distinct
B) map
C) filter
D) limit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
63
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.

A) mapped
B) map
C) mapper
D) mapping
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
64
Terminal Stream operation ________ performs processing on every element in a stream (e.g., display each element).

A) forNext
B) for
C) forAll
D) forEach
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
65
Stream mutable reduction operation ________creates an array containing the results of the stream's prior operations.

A) array
B) createArray
C) toArray
D) reduceArray
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
66
Intermediate Stream operation ________ results in a stream with the specified number of elements from the beginning of the original stream.

A) distinct
B) map
C) filter
D) limit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
67
Stream reduction operation ________ uses the elements of a collection to produce a single value using an associative accumulation function (e.g., a lambda that adds two elements).

A) reduce
B) condense
C) combine
D) associate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 67 في هذه المجموعة.