Final Exam

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

\Which statement is false? a. a. All built-in collections are synchronized. b. b. Concurrent access to a Collection by multiple threads could cause indeterminate results or fatal errors. c. c. To prevent potential threading problems, synchronization wrappers are used around collection classes that might be accessed by multiple threads. d. d. A synchronization wrapper class receives method calls, adds some functionality for thread safety and then delegates the calls to the wrapped class.

All built-in collections are synchronized. Actually, most built-in collections are unsynchronized by default for performance reasons

Functional interface Comparator's default method ________ reverses an existing Comparator's ordering. a. invert b. descending c. reversed d. downward

c. reversed

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.

c. Method range produces a sequence of values from its first argument up to its second argument. Actually, method range produces a sequence of values from its first argument up to, but not including, its second argument

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

c. source.

\Collections method __________ returns true if two Collections have no elements in common. a. a. shuffle. b. b. contains. c. c. hasCommon. d. d. disjoint.

disjoint

\Which of the following performs an unboxing conversion? Assume x refers to an Integer object. a. a. int y = x; b. b. Integer y = x; c. c. Neither of the above. d. d. Both of the above

int y = x;

\Which statement is false? a. a. A List is a Collection. b. b. A List cannot contain duplicate elements. c. c. A List is sometimes called a sequence. d. d. Lists use zero-based indices.

A List cannot contain duplicate elements. Actually, a List can contain duplicate elements

\Which statement about hashing is false? a. a. Hashing facilitates high-speed storing and retrieval of data. b. b. Two different data items can hash to the same cell; this is called a collision. c. c. A load factor of 0.5 usually results in good hashing performance, but less efficient utilization of memory. d. d. A load factor of 1.0 usually results in good hashing performance, but less efficient utilization of memory

A load factor of 1.0 usually results in good hashing performance, but less efficient utilization of memory. Actually, the reverse is true

\If the desired Object is not found, binarySearch returns __________. a. a. a positive value b. b. zero c. c. a negative value d. d. an ObjectNotFoundError

A negative value

Stream method ________ eliminates duplicate objects in a stream. a. distinct b. discrete c. unique d. different

A. distinct

Which of the following statements is false? a. A lambda can use the outer class's this reference without qualifying it with the outer class's name. b. 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. c. Lambdas may use only final local variables. d. A lambda that refers to a local variable in the enclosing lexical scope is known as a capturing lambda.

c. Lambdas may use only final local variables. Actually, lambdas may use final local variables or effectively final local variables.

________ 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

c. Mapping

\If no elements are in the Stack, method pop throws an __________. a. a. OutOfMemoryError. b. b. OutOfMemoryException. c. c. EmptyStackError. d. d. EmptyStackException

EmptyStackException

\Which statement is false? a. a. Java does not guarantee which item will be found first when a binarySearch is performed on a List containing multiple elements equivalent to the search key. b. b. If the search key is found, method binarySearch returns the List index (position relative to 1) of the element containing the search key. c. c. The binary search algorithm is fast. d. d. Method binarySearch takes a List as the first argument

If the search key is found, method binarySearch returns the List index (position relative to 1) of the element containing the search key. Actually, it returns the position relative to zero

\Which of the following performs a boxing conversion? a. a. int x = 7; b. b. Integer x = 7; c. c. Neither of the above. d. d. Both of the above

Integer x = 7;

\A(n) __________ allows a program to walk through the collection and remove elements from the collection. a. Set. b. Queue. c. Iterator. d. List.

Iterator

\Which statement is false? a. a. When a List is backed by an array, any modifications made through the List view change the array. b. b. When a List is backed by an array, any modifications made to the array change the List view. c. c. The only operation permitted on the view returned by Arrays method asList is delete, which deletes the value from the view and the backing array. d. d. Adding elements to the view returned by Arrays method asList results in an UnsupportedOperationException.

The only operation permitted on the view returned by Arrays method asList is delete, which deletes the value from the view and the backing array. Actually, the only operation permitted on the view returned by asList is set, which changes the value of the view and the backing array

\Which statement is false? a. a. The Collections API provides a set of public static methods for converting collections to unmodifiable versions. b. b. Unmodifable wrappers throw ModificationExceptions if attempts are made to modify the collection. c. c. You can use an unmodifiable wrapper to create a collection that offers read-only access to others while allowing read-write access to yourself. d. d. You can create the kind of collection mentioned in part (c) simply by giving others a reference to the unmodifiable wrapper while you also retain a reference to the wrapped collection itself.

Unmodifable wrappers throw ModificationExceptions if attempts are made to modify the collection. Actually, they throw UnsupportedOperationExceptions

\Which statement is false? a. a. Each primitive type has a corresponding type-wrapper class. b. b. The type-wrapper classes enable you to manipulate primitive-type values as objects. c. c. Type-wrapper classes are final, so you cannot extend them. d. d. The methods for primitive types correspond to the methods for the corresponding type-wrapper

The methods for primitive types correspond to the methods for the corresponding type-wrapper classes. Actually, primitive types do not have methods

Which of these is not an example of a "real-life" collection? a. a. The cards you hold in a card game. b. b. Your favorite songs stored in your computer. c. c. The players on a soccer team. d. d. The number of pages in a book.

The number of pages in a book

\Comparator method compare should return ________ if the first argument is greater than the second argument. a. a. a positive int value. b. b. zero. c. c. a negative int value. d. d. a String.

a positive int value

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>

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

a. Files method lines creates a String containing the lines of text from a file. Actually, Files method lines creates a Stream<String> for reading the lines of text from a file.

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

a. Lists.

________ 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

a. Math::sqrt

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

a. Optional.

Which of the following statements is false? a. Stream method sort 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.

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.

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>

The intermediate Stream operation ________ results in a stream containing only the unique elements. a. distinct b. map c. filter d. limit

a. distinct

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

a. reduce

Class Array's ________ method is used to create a Stream from an array of objects. a. stream b. arrayToStream c. createStream d. objectToStream

a. stream.

\The collections framework provides various __________ collection interfaces from which the programmer can quickly "flesh out" complete customized implementations. a. a. abstract. b. b. concrete. c. c. structured. d. d. unstructured.

abstract

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 (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)

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. Actually, the parameter and return types are determined by the lambda's context

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.

b. A reference is a shorthand notation for a lambda expression. Actually, a method reference is a shorthand notation for a lambda expression

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>

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.

c. On the Comparator for the first field, you call method comparing with the second Function. Actually, you call method thenComparing with the second Function

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>

________ 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

c. TreeMap::new

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

c. counting

The intermediate Stream operation ________ results in a stream containing only the elements that satisfy a condition. a. distinct b. map c. filter d. limit

c. filter

Map method ________ performs an operation on each key-value pair. a. for b. forNext c. forEach d. forAll

c. forEach

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

c. lazy.

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. reductions.

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

c. the lambda has an empty parameter list

Stream mutable reduction operation ________creates an array containing the results of the stream's prior operations. a. array b. createArray c. toArray d. reduceArray

c. toArray

\Method shuffle is a member of __________. a. a. class Arrays. b. b. class Collections. c. c. interface Collection. d. d. Interface List.

class Collections

\Map method ________ is used to determine whether a map contains a mapping for the specified key. a. a. containsKey b. b. hasKey c. c. containsMapping d. d. hasMapping

containsKey

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

d. summaryStatistics

\Iterator method __________ determines whether the Collection contains more elements. a. a. hasNext. b. b. next. c. c. contains. d. d. containsNext

hasNext

\The classes and interfaces which comprise the collections framework are members of package ________. a. a. java.util. b. b. javax.swing. c. c. java.collections. d. d. java.collection

java.util

\To find the smallest and largest element of a Collection, use Collections methods _________ and __________. a. a. least, greatest. b. b. smallest, largest. c. c. first, last. d. d. min, max.

min, max

\PriorityQueue method __________ inserts an element at the appropriate location in the queue. a. a. offer. b. b. push. c. c. poll. d. d. peek

offer

\Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value mapping is a __________ mapping. a. a. many-to-many. b. b. many-to-one. c. c. one-to-many. d. d. one-to-one.

one-to-one

\Stack method __________ looks at the top element of a stack without removing that element. a. a. glance. b. b. peek. c. c. look. d. d. sample.

peek

\A Properties object is a __________ Hashtable object. a. a. transient. b. b. persistent. c. c. polymorphic. d. d. protected

persistent

\The collections framework algorithms are __________, i.e., each of these algorithms can operate on objects that implement specified interfaces without concern for the underlying implementations. a. a. stable. b. b. lexicographical. c. c. polymorphic. d. d. implementation dependent

polymorphic

\Collections method ___________ returns a Comparator object that orders the collection's elements in reverse order. a. a. rotate. b. b. shuffle. c. c. reverse. d. d. reverseOrder.

reverseOrder

\Objects of many classes can now be output and input with Java's object __________. a. a. encapsulation. b. b. overloading. c. c. serialization. d. d. reflection.

serialization

\Algorithm __________ randomly orders a List's elements. a. a. randomShuffle. b. b. randomPlacement. c. c. fiftyTwoCardPickup. d. d. shuffle.

shuffle

\Which of the following is not an abstract implementation provided by the collections framework? a. a. AbstractCollection. b. b. AbstractTree. c. c. AbstractMap. d. d. AbstractList.

AbstractTree

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

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

C. mapToDouble

\Which statement is false? a. a. A ListIterator accesses the elements of a List. b. b. Class ArrayList is a fixed-size array. c. c. A LinkedList is a linked list implementation of a List. d. d. ArrayLists execute faster than Vectors because they are not thread safe.

Class ArrayList is a fixed-size array. Actually, ArrayList is a dynamically resizable array-like data structure.

\Which statement is false? a. a. SortedSet extends Set. b. b. Class SortedSet implements TreeSet. c. c. When a HashSet is constructed, it removes any duplicates in the Collection. d. d. By definition, a Set object does not contain any duplicates.

Class SortedSet implements TreeSet. Actually, SortedSet is an interface implemented by class TreeSet

\Which statement is false? a. a. A collection is an object that can hold references to other objects. b. b. The collection interfaces declare the operations that can be performed on each type of collection. c. c. Collections discourage software reuse because they are non-portable. d. d. Collections are carefully constructed for rapid execution and efficient use of memory.

Collections discourage software reuse because they are non-portable. Actually, they encourage software reuse because they are portable

\Collections method sort that accepts a List as an argument. It sorts the List elements, which must implement the __________ interface. a. a. Comparable. b. b. Comparator. c. c. Compare. d. d. Ordering.

Comparable

\Java supports type inferencing with the <> notation in statements that declare and create generic type variables and objects. For example, the following line: List<String> list = new ArrayList<String>(); can be written as: a. List<> list = new ArrayList<>(); b. List<> list = new ArrayList<String>(); c. List<String> list = new ArrayList<>(); d. List<String> list = new ArrayList();

List<String> list = new ArrayList<>();

\Which of the following does not implement interface List? a. a. ArrayList. b. b. LinkedList. c. c. Vector. d. d. ListIterator.

ListIterator

\Class Collections provides algorithms for reversing, filling and copying ________. a. a. Lists. b. b. Collections. c. c. Arrays. d. d. Stacks.

Lists

\Which statement is false? a. a. Queue is a new collection interface introduced in J2SE 5.0. b. b. Queue and PriorityQueue are included in the java.util package. c. c. PriorityQueue orders elements in increasing order, so that smallest value will be the first element removed from PriorityQueue. d. d. Queue extends interface Collection

PriorityQueue orders elements in increasing order, so that smallest value will be the first element removed from PriorityQueue. Actually, PriorityQueue orders elements in their natural order as specified by interface Comparable

\methods enable a program to view a portion of a collection. a. a. Focus-view. b. b. Range-view. c. c. Delimiter-view. d. d. Subset-view.

Range-view

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.

b. Interface IntPredicate's default method invert reverses the boolean value of the IntPredicate on which it's called. Actually, Interface IntPredicate's default method negate reverses the boolean value of the IntPredicate on which it's called.

________ 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

b. System.out::println

Which of the following statements is false? a. Prior to functional programming, you typically determined what you wanted to accomplish, then specified the precise steps to accomplish that task. b. Using a loop to iterate over a collection of elements is known as external iteration and requires accessing the elements sequentially. Such iteration also requires mutable variables. External iteration is easier to parallelize. c. Letting the library determine how to iterate over a collection of elements is known as internal iteration. d. Functional programming focuses on immutability—not modifying the data source being processed or any other program state

b. Using a loop to iterate over a collection of elements is known as external iteration and requires accessing the elements sequentially. Such iteration also requires mutable variables. External iteration is easier to parallelize. Actually, internal iteration is easier to parallelize.

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

b. downstream

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

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

b. identity.

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

b. map

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

b. short circuit

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

b. the natural order for the stream's element type

\LinkedList method listIterator returns a(n) __________. a. a. Iterator. b. b. List. c. c. sub list. d. d. bidirectional iterator

bidirectional iterator.

\Interface Collection contains __________ operations (i.e., operations performed on the entire collection). a. a. aggregate. b. b. composite. c. c. integral. d. d. bulk.

bulk

The new language and library capabilities that support functional programming were added to Java as part of Project ________. a. Utilitarian b. Upsilon c. Lambda d. Utility

c. Lambda

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

d. reduce.

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.

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 Actually, unlike collections, streams do not have their own storage—once a stream is processed, it cannot be reused, because it does not maintain a copy of the original data source.

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>

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.

d. Each of these statements is true

An ________ (package java.util.stream) is a specialized stream for manipulating int values. a. StreamOfInt b. IStream. c. IntegerStream d. IntStream

d. IntStream

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 implements the IntPredicate functional interface (package java.util.function). c. IntStream method sorted (a lazy operation) orders the elements of the stream into ascending order by default. All prior intermediate operations in the stream pipeline must be complete so that method sorted knows which elements to sort. d. Method filter is a stateless intermediate operation—it requires information about other elements in the stream in order to test whether the current element satisfies the predicate.

d. Method filter is a stateless intermediate operation—it requires information about other elements in the stream in order to test whether the current element satisfies the predicate. Actually, method filter is a stateless intermediate operation—it does not require any information about other elements in the stream in order to test whether the current element satisfies the predicate

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>

________ 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

d. String::toUpperCase

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

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

d. collect

Terminal operations are eager; they perform the requested operation when they are called. a. immediate b. idle c. lazy d. eager

d. eager

Terminal Stream operation ________ performs processing on every element in a stream (e.g., display each element). a. forNext b. for c. forAll d. forEach

d. forEach.

Prior to Java SE 8, Java supported three programming paradigms. Java SE 8 adds ________. a. procedural programming b. object-oriented programming c. generic programming d. functional programming.

d. functional programming

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

d. key, value

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

d. limit

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

d. overloaded.


Set pelajaran terkait

Diagnostic Testing HESI prep- Adult Care

View Set

50 Sophisticated Words You Should Start Using Instead

View Set

Chapter 19 Embracing Best Security Practices

View Set