Deck 19: Stream Processing

Full screen (f)
exit full mode
Question
Which method causes stream operations to be distributed over multiple available processors?
A.generate
B.parallel
C.distribute
D.iterate
Use Space or
up arrow
down arrow
to flip the card.
Question
You want to create a stream from an explicit specification of elements.Which method should you use?
A.Collections.stream
B.Stream.of
C.Collections.of
D.Stream.generate
Question
Complete the blanks in the following definition:
A stream is a(n) __________ sequence of values that are processed _________.
A.immutable ...eagerly
B.mutable ...eagerly
C.mutable ...lazily
D.immutable ...lazily
Question
You want to create a stream of the lines in a file with a given path.Which method should you use?
A.Paths.lines
B.Stream.of
C.Files.lines
D.Files.stream
Question
Which statement creates a set of majors from a stream of String objects, given by the variable majorsStream, representing the majors of students? Which statement creates a set of majors from a stream of String objects, given by the variable majorsStream, representing the majors of students?  <div style=padding-top: 35px>
Question
You want to create a stream from a list, set, or other collection in Java.Which method should you use?
A.iterate
B.of
C.generate
D.stream
Question
Which statement about streams and stream processing is NOT correct?
A.A stream stores its data values.
B.A stream is an immutable sequence of values.
C.Lambda expressions are often used in stream processing.
D.A stream's values are processed lazily.
Question
Which statement creates a list from a stream of Student objects, given by the variable studentStream?
A.List students = studentStream.collect(Collectors.toList());
B.List students = studentStream.toList(Student::new);
C.List students = studentStream.collect(Student[]::new);
D.List students = studentStream.toList();
Question
Which statement creates an array from a stream of Student objects, given by the variable studentStream?
A.Student[] students = studentStream.collect(Collectors.toArray());
B.Student[] students = studentStream.toArray(Student[]::new);
C.Student[] students = studentStream.toArray(new Student[]);
D.Student[] students = studentStream.toArray(new::Student[]);
Question
Assuming that the variable myStringArrayList has been populated to contain a collection of String objects, which expression finds the number of elements in a stream created from the myStringArrayList collection?
A.myStringArrayList.of().count()
B.myStringArrayList.stream().count()
C.myStringArrayList.stream().size()
D.myStringArrayList.stream().length()
Question
Which statement creates a stream from an explicit specification of words?
A.Stream words = Stream.of("The","quick","brown","fox","jumped","over","the","lazy","dog");
B.Stream words = Stream.of({"The","quick","brown","fox","jumped","over","the","lazy","dog"});
C.Stream words = Stream.stream("The","quick","brown","fox","jumped","over","the","lazy","dog");
D.Stream words = Stream.of{"The","quick","brown","fox","jumped","over","the","lazy","dog"};
Question
You want to save stream values in a list.Which method of the Stream class should you use?
A.collect
B.toArray
C.toList
D.save
Question
Which statement creates one comma-separated String from a stream called orderedHonorMajors, which is a stream of alphabetically ordered String objects representing unique majors of honors students? Which statement creates one comma-separated String from a stream called orderedHonorMajors, which is a stream of alphabetically ordered String objects representing unique majors of honors students?  <div style=padding-top: 35px>
Question
Which statement creates a stream from an explicit specification of integers?
A.Stream myStream = Stream.of({0, 1, 1, 2, 3, 5, 8, 13, 21, 34});
B.Stream myStream = Stream.of(0, 1, 1, 2, 3, 5, 8, 13, 21, 34);
C.Stream myStream = Stream.of(0, 1, 1, 2, 3, 5, 8, 13, 21, 34);
D.Stream myStream = Stream.stream({0, 1, 1, 2, 3, 5, 8, 13, 21, 34});
Question
Which statement creates a stream from an array of integers defined as shown:
Integer[] myArray = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34};
A.Stream myStream = Stream.of(myArray);
B.Stream myStream = myArray.stream();
C.Stream myStream = myArray.stream();
D.Stream myStream = Stream.of(myArray);
Question
You want to save stream values in a set.Which method of the Stream class should you use?
A.collect
B.toArray
C.save
D.toSet
Question
You want to save a stream of String values as one long string.Which method of the Stream class should you use?
A.save
B.joining
C.toString
D.collect
Question
Which of the following can NOT be used as an argument to the collect method of the Stream class.
A.Collectors.toArray()
B.Collectors.joining()
C.Collectors.toList()
D.Collectors.toSet()
Question
You want to save stream values in an array.Which method of the Stream class should you use?
A.toArray
B.save
C.collect
D.values
Question
Which code fragment creates a stream of lines from a file named "data.txt"?
A.try(Stream linesData = Files.lines(Paths.get("data.txt"))) { ...};
B.try(Stream linesData = Files.lines(Paths.get("data.txt"))) { ...};
C.try(Stream linesData = Files.lines("data.txt")) { ...};
D.try(Stream linesData = Paths.get(Files.lines("data.txt"))) { ...};
Question
Which method applies a function to all elements of a stream, yielding another stream?
A.filter
B.skip
C.map
D.limit
Question
Complete the following code snippet that returns a stream of String objects representing the majors of the students in the honors college, assuming that honorsStream is a stream of Student objects and the method getMajor returns a String.
Stream honorsMajors = honorsStream
________________________________;
A..map(getMajor())
B..filter(s -> s.getMajor())
C..filter(getMajor())
D..map(s -> s.getMajor())
Question
Which method yields a stream of all elements fulfilling a condition?
A.filter
B.limit
C.map
D.skip
Question
Complete the following code snippet that counts the number of data lines in the students.csv file, ignoring the first line that contains the field headers.
try (Stream lineStream = Files.lines(Paths.get("students.csv")))
{
long dataCount = lineStream
_____________________
.count();
}
A..take(1)
B..filter(1)
C..skip(1)
D..limit(1)
Question
Which method of the Stream class can be used to create infinite streams?
I generate
II iterate
III random
A.II only
B.I, II, and III
C.I only
D.I and II only
Question
Complete the following code snippet that returns a list of the first ten prime numbers, assuming that primes is an infinite Integer stream of prime numbers.
List first10primes = primes
________________________________
.collect(Collectors.toList());
A..limit(10)
B..count(10)
C..skip(10)
D..filter(10)
Question
Which method yields a new stream with the elements reordered by its corresponding Comparable interface implementation?
A.orderby
B.sort
C.order
D.sorted
Question
Which method yields a stream obtained by dropping a number of elements from the beginning of the stream?
A.limit
B.distinct
C.skip
D.filter
Question
What does the following lambda expression do, assuming the variable s is of type double?
s -> s + .10 * s
A.This is not a valid lambda expression.
B.Returns 10% of the value.
C.Returns .10% of the value.
D.Returns the value increased by 10%.
Question
Which method yields a stream obtained by dropping duplicate elements?
A.skip
B.limit
C.filter
D.distinct
Question
Which statement creates a list of the names of the top 3 Computer Science majors based on gpa? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Which statement creates a list of the names of the top 3 Computer Science majors based on gpa? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.  <div style=padding-top: 35px>
Question
Complete the following code snippet that alphabetically orders the honorsUniqueMajors stream of String objects representing the unique majors of the students in the honors college.
Stream orderedHonorsMajors = honorsUniqueMajors
________________________________;
A..sort()
B..order()
C..sorted()
D..orderby()
Question
Which statement creates a list of names in alphabetical order of Computer Science majors? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively. Which statement creates a list of names in alphabetical order of Computer Science majors? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.  <div style=padding-top: 35px>
Question
Which statement about lambda expressions is NOT correct?
A.The body of a lambda expression must consist of a single expression.
B.A lambda expression can have an optional parameter type.
C.A lambda expression can be converted to an instance of a functional interface, which is an interface with a single abstract method.
D.A lambda expression can have multiple parameters.
Question
Complete the following code snippet that removes the duplicates from the honorsMajors stream of String objects representing the majors of the students in the honors college.
Stream honorsUniqueMajors = honorsMajors
________________________________;
A..distinct()
B..skip()
C..filter()
D..unique()
Question
Which statement creates a stream of String objects representing the unique majors of students in alphabetical order? Assume that studentStream is a stream of Student objects and the getMajor method returns a String representing the student's major. Which statement creates a stream of String objects representing the unique majors of students in alphabetical order? Assume that studentStream is a stream of Student objects and the getMajor method returns a String representing the student's major.  <div style=padding-top: 35px>
Question
Which statement creates an infinite stream of even numbers?
A.Stream evens = Stream.iterate(2, n -> n + 2);
B.Stream evens = Stream.range(n -> n + 2);
C.Stream evens = Stream.generate(n -> n + 2);
D.Stream evens = Stream.generator(2, n -> n + 2);
Question
Which method yields a stream restricted to a number of elements in the beginning of the stream?
A.filter
B.skip
C.distinct
D.limit
Question
Which statement creates an infinite stream of lottery numbers in the range of 1 to 50?
A.Stream lotteryNumbers = Stream.iterate(() -> 1 + (int)(50 * Math.random()));
B.Stream lotteryNumbers = Stream.generator(() -> 1 + (int)(50 * Math.random()));
C.Stream lotteryNumbers = Stream.range(() -> 1 + (int)(50 * Math.random()));
D.Stream lotteryNumbers = Stream.generate(() -> 1 + (int)(50 * Math.random()));
Question
Complete the following code snippet that returns a stream of Student objects, representing students who have a grade point average (gpa) of at least 3.8.Assume that studentStream is a stream of Student objects and the getGpa method returns a double representing the student's gpa.
Stream highHonors = studentStream
________________________________;
A..map(getGpa() >= 3.8)
B..filter(getGpa() >= 3.8)
C..map(s -> s.getGpa() >= 3.8)
D..filter(s -> s.getGpa() >= 3.8)
Question
A __________ operation triggers the lazy operations on a stream and yields a non-stream value.
A.parallel
B.terminal
C.non-terminal
D.distributed
Question
Which lambda expression represents a function that computes a 10% raise to an employee's salary?
A.s -> 1 + .10 * s
B.s -> s + .01 * s
C.s -> s * .10
D.s -> s + .10 * s
Question
Complete the following code snippet that displays a student's major, assuming that the method findStudentByID takes a student id as input and returns a result of type Optional.Also, assume the getMajor method returns a String representing the student's major.
Optional studentSearch = findStudentByID("123456789");
if (____________________)
{
System.out.println(studentSearch.get().getMajor());
}
else
{
System.out.println("Student does not exist");
}
A.studentSearch != null
B.studentSearch != Optional.empty()
C.studentSearch.isPresent()
D.studentSearch.ifPresent()
Question
The method reference System.out::println is a shorthand for which expression?
A.() -> System.out.println(n)
B.() -> System.out.println()
C.n -> System.out.println(n)
D.System.out.println()
Question
Complete the code to sort the employees collection by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer.
Collections.sort(employees, _____________________________________);
A.Comparator.comparing(Employee::getSalary)
B.Comparator.comparing(Employee::getSalary())
C.Comparator.thenComparing(Employee::getSalary)
D.Comparator.comparing(e -> e.getSalary)
Question
Complete the following code snippet that returns the name of an employee who is a Database Administrator or "None" if there are no such titled employees. Complete the following code snippet that returns the name of an employee who is a Database Administrator or None if there are no such titled employees.  <div style=padding-top: 35px>
Question
What does the following lambda expression do, assuming the variable p is of type double and the variable q is of type int?
(p, q) -> p * q
A.Returns the quotient of p and q.
B.Returns the value of p multiplied by q.
C.This is not a valid lambda expression.
D.Returns the average of p and q.
Question
The constructor reference Student[]::new is a shorthand for which expression?
A.n -> new Student[]
B.n -> new Student[n]
C.() -> new Student[]
D.() -> new Student()
Question
Which statement about higher-order functions is NOT correct?
A.A higher-order function is a function that consumes functions.
B.filter is considered to be a higher-order function.
C.Implementing a higher-order function in Java uses a functional interface, which is an interface with a single abstract method.
D.A higher-order function cannot return a function.
Question
Complete the following code snippet that checks a log for any error message and sends an alert with the message found using the alert method. Complete the following code snippet that checks a log for any error message and sends an alert with the message found using the alert method.  <div style=padding-top: 35px>
Question
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 3 with the Java code to return an empty result.
A.return Optional.empty();
B.return Optional.empty(result);
C.return result.empty();
D.return null;
Question
Which of the following statements related to the Optional type is NOT correct?
A.The Optional.orElse method obtains the value of an Optional or, if no value is present, the value given by its parameter.
B.The findFirst method on a stream returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty.
C.The Optional.of method creates a stream of Optional objects provided as an explicit parameter.
D.The Optional class is a wrapper for objects that may or may not be present, which is typically used in results for stream processing.
Question
Which of the following is NOT a method for the Optional class?
A.present
B.empty
C.of
D.orElse
Question
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 2 with the Java code to return the result.
A.return result.get();
B.return Optional.empty();
C.return Optional;
D.return Optional.of(result);
Question
Which Java interface is NOT a functional interface?
A.Predicate
B.Comparator
C.Collection
D.ActionListener
Question
Which of the following statements does NOT return a value of type Optional, assuming that the variable result is of type Optional?
A.return result.orElse("None");
B.return Optional.empty();
C.return result;
D.return Optional.of("None");
Question
Complete the code to sort the employees collection by title and within title by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer and the method getTitle that returns an employee's title as a String.
Collections.sort(employees, Comparator___________________________);
A..comparing(Employee::getSalary).thenComparing(Employee::getTitle)
B..comparing(Employee::getTitle).thenComparing(Employee::getSalary)
C..thenComparing(Employee::getSalary).comparing(Employee::getTitle)
D..thenComparing(Employee::getTitle).comparing(Employee::getSalary)
Question
Which lambda expression represents a function that given the price and quantity of an item to purchase computes the cost of the quantity of that item on the invoice?
A.p, q -> p * q
B.(p, q) -> p + q
C.(p, q) -> p * q
D.p, q -> p + q
Question
Complete the following code snippet, assuming that method findEmployeeByID takes an employee id as input and returns a result of type Optional and method displayEmployee takes an Employee object as input and displays the employee's information.
Optional empSearch = findEmployeeByID("123456789");
if (empSearch.isPresent())
{
_____________________________
}
else
{
System.out.println("Employee does not exist");
}
A.displayEmployee(get(empSearch);
B.displayEmployee(empSearch.get());
C.displayEmployee(empSearch);
D.displayEmployee(empSearch.of());
Question
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 1 with the Java code to determine whether there is a result.
A.if (result.ifPresent())
B.if (result == null)
C.if (result != null)
D.if (result.isPresent())
Question
Complete the following statement that uses streams to display the names of employees in an ArrayList called employees of Employee objects that have a getName method to return the employee's name as a String. Complete the following statement that uses streams to display the names of employees in an ArrayList called employees of Employee objects that have a getName method to return the employee's name as a String.  <div style=padding-top: 35px>
Question
Which of the following terminal operations on a generic Stream does NOT return an Optional?
A.anyMatch
B.max
C.findAny
D.findFirst
Question
Complete the following statement that finds the minimum salary of employees who are Managers.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title. Complete the following statement that finds the minimum salary of employees who are Managers.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title.   A.OptionalInt B.int C.Optional<Integer> D.Integer<div style=padding-top: 35px>
A.OptionalInt
B.int
C.Optional
D.Integer
Question
Which of the following terminal operations does NOT return a result?
A.toArray
B.collect
C.forEach
D.allMatch
Question
Complete the following statement that finds the average salary of employees who are Database Administrators.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title. Complete the following statement that finds the average salary of employees who are Database Administrators.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title.   A.Optional<Double> B.OptionalDouble C.double D.Double<div style=padding-top: 35px>
A.Optional
B.OptionalDouble
C.double
D.Double
Question
Complete the following code snippet to display the orderedHonorsMajors stream of alphabetically ordered String objects, representing the unique majors of the students in the honors college. Complete the following code snippet to display the orderedHonorsMajors stream of alphabetically ordered String objects, representing the unique majors of the students in the honors college.  <div style=padding-top: 35px>
Question
Which of the following terminal operations does NOT return a boolean?
A.anyMatch
B.noneMatch
C.allMatch
D.findAny
Question
Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.  <div style=padding-top: 35px>
Question
Complete the following statement that finds the average salary of employees.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer. Complete the following statement that finds the average salary of employees.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.  <div style=padding-top: 35px>
Question
Complete the following statement that uses streams to find the length of the longest employee name.Assume that employeeStream is a stream of Employee objects and the getName method returns a String representing the employee's name. Complete the following statement that uses streams to find the length of the longest employee name.Assume that employeeStream is a stream of Employee objects and the getName method returns a String representing the employee's name.  <div style=padding-top: 35px>
Question
Complete the following statement that finds the total cost of raising all employee salaries by 10%.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer. Complete the following statement that finds the total cost of raising all employee salaries by 10%.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.  <div style=padding-top: 35px>
Question
Which of the following is NOT a correct statement about primitive-type streams?
A.An IntStream is a stream of Integer objects.
B.The methods for streams are also applicable to a primitive-type stream.
C.An IntStream is more efficient than Stream.
D.A primitive-type stream has a sum method.
Question
Complete the following code snippet to determine whether all honors students included in the honorsMajors stream of Student objects have a grade point average of at least 3.0, assuming the method getGpa returns the student's gpa as a double. Complete the following code snippet to determine whether all honors students included in the honorsMajors stream of Student objects have a grade point average of at least 3.0, assuming the method getGpa returns the student's gpa as a double.  <div style=padding-top: 35px>
Question
Complete the following statement that uses streams to create test data by appending a number to a string. Complete the following statement that uses streams to create test data by appending a number to a string.  <div style=padding-top: 35px>
Question
Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.  <div style=padding-top: 35px>
Question
Which of the following expressions returns an IntStream, assuming that generator is an instance of type Random?
A.generator.int(1,7)
B.generator.nextInts()
C."Hello World".codePoints()
D.Stream.of(1,3,5,7,9)
Question
Which of the following is NOT a terminal operation?
A.count
B.distinct
C.allMatch
D.collect
Question
Complete the following code snippet to find the highest paid Database Administrator.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer. Complete the following code snippet to find the highest paid Database Administrator.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer.  <div style=padding-top: 35px>
Question
Complete the following code snippet that determines whether all Managers earn more than 100,000.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer. Complete the following code snippet that determines whether all Managers earn more than 100,000.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer.  <div style=padding-top: 35px>
Question
Which of the following is NOT a primitive-type stream?
A.IntStream
B.DoubleStream
C.LongStream
D.FloatStream
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/85
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 19: Stream Processing
1
Which method causes stream operations to be distributed over multiple available processors?
A.generate
B.parallel
C.distribute
D.iterate
parallel
2
You want to create a stream from an explicit specification of elements.Which method should you use?
A.Collections.stream
B.Stream.of
C.Collections.of
D.Stream.generate
Stream.of
3
Complete the blanks in the following definition:
A stream is a(n) __________ sequence of values that are processed _________.
A.immutable ...eagerly
B.mutable ...eagerly
C.mutable ...lazily
D.immutable ...lazily
immutable ...lazily
4
You want to create a stream of the lines in a file with a given path.Which method should you use?
A.Paths.lines
B.Stream.of
C.Files.lines
D.Files.stream
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
5
Which statement creates a set of majors from a stream of String objects, given by the variable majorsStream, representing the majors of students? Which statement creates a set of majors from a stream of String objects, given by the variable majorsStream, representing the majors of students?
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
6
You want to create a stream from a list, set, or other collection in Java.Which method should you use?
A.iterate
B.of
C.generate
D.stream
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
7
Which statement about streams and stream processing is NOT correct?
A.A stream stores its data values.
B.A stream is an immutable sequence of values.
C.Lambda expressions are often used in stream processing.
D.A stream's values are processed lazily.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
8
Which statement creates a list from a stream of Student objects, given by the variable studentStream?
A.List students = studentStream.collect(Collectors.toList());
B.List students = studentStream.toList(Student::new);
C.List students = studentStream.collect(Student[]::new);
D.List students = studentStream.toList();
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
9
Which statement creates an array from a stream of Student objects, given by the variable studentStream?
A.Student[] students = studentStream.collect(Collectors.toArray());
B.Student[] students = studentStream.toArray(Student[]::new);
C.Student[] students = studentStream.toArray(new Student[]);
D.Student[] students = studentStream.toArray(new::Student[]);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
10
Assuming that the variable myStringArrayList has been populated to contain a collection of String objects, which expression finds the number of elements in a stream created from the myStringArrayList collection?
A.myStringArrayList.of().count()
B.myStringArrayList.stream().count()
C.myStringArrayList.stream().size()
D.myStringArrayList.stream().length()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
11
Which statement creates a stream from an explicit specification of words?
A.Stream words = Stream.of("The","quick","brown","fox","jumped","over","the","lazy","dog");
B.Stream words = Stream.of({"The","quick","brown","fox","jumped","over","the","lazy","dog"});
C.Stream words = Stream.stream("The","quick","brown","fox","jumped","over","the","lazy","dog");
D.Stream words = Stream.of{"The","quick","brown","fox","jumped","over","the","lazy","dog"};
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
12
You want to save stream values in a list.Which method of the Stream class should you use?
A.collect
B.toArray
C.toList
D.save
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
13
Which statement creates one comma-separated String from a stream called orderedHonorMajors, which is a stream of alphabetically ordered String objects representing unique majors of honors students? Which statement creates one comma-separated String from a stream called orderedHonorMajors, which is a stream of alphabetically ordered String objects representing unique majors of honors students?
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
14
Which statement creates a stream from an explicit specification of integers?
A.Stream myStream = Stream.of({0, 1, 1, 2, 3, 5, 8, 13, 21, 34});
B.Stream myStream = Stream.of(0, 1, 1, 2, 3, 5, 8, 13, 21, 34);
C.Stream myStream = Stream.of(0, 1, 1, 2, 3, 5, 8, 13, 21, 34);
D.Stream myStream = Stream.stream({0, 1, 1, 2, 3, 5, 8, 13, 21, 34});
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
15
Which statement creates a stream from an array of integers defined as shown:
Integer[] myArray = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34};
A.Stream myStream = Stream.of(myArray);
B.Stream myStream = myArray.stream();
C.Stream myStream = myArray.stream();
D.Stream myStream = Stream.of(myArray);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
16
You want to save stream values in a set.Which method of the Stream class should you use?
A.collect
B.toArray
C.save
D.toSet
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
17
You want to save a stream of String values as one long string.Which method of the Stream class should you use?
A.save
B.joining
C.toString
D.collect
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following can NOT be used as an argument to the collect method of the Stream class.
A.Collectors.toArray()
B.Collectors.joining()
C.Collectors.toList()
D.Collectors.toSet()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
19
You want to save stream values in an array.Which method of the Stream class should you use?
A.toArray
B.save
C.collect
D.values
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
20
Which code fragment creates a stream of lines from a file named "data.txt"?
A.try(Stream linesData = Files.lines(Paths.get("data.txt"))) { ...};
B.try(Stream linesData = Files.lines(Paths.get("data.txt"))) { ...};
C.try(Stream linesData = Files.lines("data.txt")) { ...};
D.try(Stream linesData = Paths.get(Files.lines("data.txt"))) { ...};
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
21
Which method applies a function to all elements of a stream, yielding another stream?
A.filter
B.skip
C.map
D.limit
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
22
Complete the following code snippet that returns a stream of String objects representing the majors of the students in the honors college, assuming that honorsStream is a stream of Student objects and the method getMajor returns a String.
Stream honorsMajors = honorsStream
________________________________;
A..map(getMajor())
B..filter(s -> s.getMajor())
C..filter(getMajor())
D..map(s -> s.getMajor())
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
23
Which method yields a stream of all elements fulfilling a condition?
A.filter
B.limit
C.map
D.skip
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
24
Complete the following code snippet that counts the number of data lines in the students.csv file, ignoring the first line that contains the field headers.
try (Stream lineStream = Files.lines(Paths.get("students.csv")))
{
long dataCount = lineStream
_____________________
.count();
}
A..take(1)
B..filter(1)
C..skip(1)
D..limit(1)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
25
Which method of the Stream class can be used to create infinite streams?
I generate
II iterate
III random
A.II only
B.I, II, and III
C.I only
D.I and II only
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
26
Complete the following code snippet that returns a list of the first ten prime numbers, assuming that primes is an infinite Integer stream of prime numbers.
List first10primes = primes
________________________________
.collect(Collectors.toList());
A..limit(10)
B..count(10)
C..skip(10)
D..filter(10)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
27
Which method yields a new stream with the elements reordered by its corresponding Comparable interface implementation?
A.orderby
B.sort
C.order
D.sorted
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
28
Which method yields a stream obtained by dropping a number of elements from the beginning of the stream?
A.limit
B.distinct
C.skip
D.filter
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
29
What does the following lambda expression do, assuming the variable s is of type double?
s -> s + .10 * s
A.This is not a valid lambda expression.
B.Returns 10% of the value.
C.Returns .10% of the value.
D.Returns the value increased by 10%.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
30
Which method yields a stream obtained by dropping duplicate elements?
A.skip
B.limit
C.filter
D.distinct
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
31
Which statement creates a list of the names of the top 3 Computer Science majors based on gpa? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Which statement creates a list of the names of the top 3 Computer Science majors based on gpa? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
32
Complete the following code snippet that alphabetically orders the honorsUniqueMajors stream of String objects representing the unique majors of the students in the honors college.
Stream orderedHonorsMajors = honorsUniqueMajors
________________________________;
A..sort()
B..order()
C..sorted()
D..orderby()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
33
Which statement creates a list of names in alphabetical order of Computer Science majors? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively. Which statement creates a list of names in alphabetical order of Computer Science majors? Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
34
Which statement about lambda expressions is NOT correct?
A.The body of a lambda expression must consist of a single expression.
B.A lambda expression can have an optional parameter type.
C.A lambda expression can be converted to an instance of a functional interface, which is an interface with a single abstract method.
D.A lambda expression can have multiple parameters.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
35
Complete the following code snippet that removes the duplicates from the honorsMajors stream of String objects representing the majors of the students in the honors college.
Stream honorsUniqueMajors = honorsMajors
________________________________;
A..distinct()
B..skip()
C..filter()
D..unique()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
36
Which statement creates a stream of String objects representing the unique majors of students in alphabetical order? Assume that studentStream is a stream of Student objects and the getMajor method returns a String representing the student's major. Which statement creates a stream of String objects representing the unique majors of students in alphabetical order? Assume that studentStream is a stream of Student objects and the getMajor method returns a String representing the student's major.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
37
Which statement creates an infinite stream of even numbers?
A.Stream evens = Stream.iterate(2, n -> n + 2);
B.Stream evens = Stream.range(n -> n + 2);
C.Stream evens = Stream.generate(n -> n + 2);
D.Stream evens = Stream.generator(2, n -> n + 2);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
38
Which method yields a stream restricted to a number of elements in the beginning of the stream?
A.filter
B.skip
C.distinct
D.limit
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
39
Which statement creates an infinite stream of lottery numbers in the range of 1 to 50?
A.Stream lotteryNumbers = Stream.iterate(() -> 1 + (int)(50 * Math.random()));
B.Stream lotteryNumbers = Stream.generator(() -> 1 + (int)(50 * Math.random()));
C.Stream lotteryNumbers = Stream.range(() -> 1 + (int)(50 * Math.random()));
D.Stream lotteryNumbers = Stream.generate(() -> 1 + (int)(50 * Math.random()));
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
40
Complete the following code snippet that returns a stream of Student objects, representing students who have a grade point average (gpa) of at least 3.8.Assume that studentStream is a stream of Student objects and the getGpa method returns a double representing the student's gpa.
Stream highHonors = studentStream
________________________________;
A..map(getGpa() >= 3.8)
B..filter(getGpa() >= 3.8)
C..map(s -> s.getGpa() >= 3.8)
D..filter(s -> s.getGpa() >= 3.8)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
41
A __________ operation triggers the lazy operations on a stream and yields a non-stream value.
A.parallel
B.terminal
C.non-terminal
D.distributed
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
42
Which lambda expression represents a function that computes a 10% raise to an employee's salary?
A.s -> 1 + .10 * s
B.s -> s + .01 * s
C.s -> s * .10
D.s -> s + .10 * s
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
43
Complete the following code snippet that displays a student's major, assuming that the method findStudentByID takes a student id as input and returns a result of type Optional.Also, assume the getMajor method returns a String representing the student's major.
Optional studentSearch = findStudentByID("123456789");
if (____________________)
{
System.out.println(studentSearch.get().getMajor());
}
else
{
System.out.println("Student does not exist");
}
A.studentSearch != null
B.studentSearch != Optional.empty()
C.studentSearch.isPresent()
D.studentSearch.ifPresent()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
44
The method reference System.out::println is a shorthand for which expression?
A.() -> System.out.println(n)
B.() -> System.out.println()
C.n -> System.out.println(n)
D.System.out.println()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
45
Complete the code to sort the employees collection by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer.
Collections.sort(employees, _____________________________________);
A.Comparator.comparing(Employee::getSalary)
B.Comparator.comparing(Employee::getSalary())
C.Comparator.thenComparing(Employee::getSalary)
D.Comparator.comparing(e -> e.getSalary)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
46
Complete the following code snippet that returns the name of an employee who is a Database Administrator or "None" if there are no such titled employees. Complete the following code snippet that returns the name of an employee who is a Database Administrator or None if there are no such titled employees.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
47
What does the following lambda expression do, assuming the variable p is of type double and the variable q is of type int?
(p, q) -> p * q
A.Returns the quotient of p and q.
B.Returns the value of p multiplied by q.
C.This is not a valid lambda expression.
D.Returns the average of p and q.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
48
The constructor reference Student[]::new is a shorthand for which expression?
A.n -> new Student[]
B.n -> new Student[n]
C.() -> new Student[]
D.() -> new Student()
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
49
Which statement about higher-order functions is NOT correct?
A.A higher-order function is a function that consumes functions.
B.filter is considered to be a higher-order function.
C.Implementing a higher-order function in Java uses a functional interface, which is an interface with a single abstract method.
D.A higher-order function cannot return a function.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
50
Complete the following code snippet that checks a log for any error message and sends an alert with the message found using the alert method. Complete the following code snippet that checks a log for any error message and sends an alert with the message found using the alert method.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
51
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 3 with the Java code to return an empty result.
A.return Optional.empty();
B.return Optional.empty(result);
C.return result.empty();
D.return null;
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
52
Which of the following statements related to the Optional type is NOT correct?
A.The Optional.orElse method obtains the value of an Optional or, if no value is present, the value given by its parameter.
B.The findFirst method on a stream returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty.
C.The Optional.of method creates a stream of Optional objects provided as an explicit parameter.
D.The Optional class is a wrapper for objects that may or may not be present, which is typically used in results for stream processing.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
53
Which of the following is NOT a method for the Optional class?
A.present
B.empty
C.of
D.orElse
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
54
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 2 with the Java code to return the result.
A.return result.get();
B.return Optional.empty();
C.return Optional;
D.return Optional.of(result);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
55
Which Java interface is NOT a functional interface?
A.Predicate
B.Comparator
C.Collection
D.ActionListener
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
56
Which of the following statements does NOT return a value of type Optional, assuming that the variable result is of type Optional?
A.return result.orElse("None");
B.return Optional.empty();
C.return result;
D.return Optional.of("None");
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
57
Complete the code to sort the employees collection by title and within title by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer and the method getTitle that returns an employee's title as a String.
Collections.sort(employees, Comparator___________________________);
A..comparing(Employee::getSalary).thenComparing(Employee::getTitle)
B..comparing(Employee::getTitle).thenComparing(Employee::getSalary)
C..thenComparing(Employee::getSalary).comparing(Employee::getTitle)
D..thenComparing(Employee::getTitle).comparing(Employee::getSalary)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
58
Which lambda expression represents a function that given the price and quantity of an item to purchase computes the cost of the quantity of that item on the invoice?
A.p, q -> p * q
B.(p, q) -> p + q
C.(p, q) -> p * q
D.p, q -> p + q
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
59
Complete the following code snippet, assuming that method findEmployeeByID takes an employee id as input and returns a result of type Optional and method displayEmployee takes an Employee object as input and displays the employee's information.
Optional empSearch = findEmployeeByID("123456789");
if (empSearch.isPresent())
{
_____________________________
}
else
{
System.out.println("Employee does not exist");
}
A.displayEmployee(get(empSearch);
B.displayEmployee(empSearch.get());
C.displayEmployee(empSearch);
D.displayEmployee(empSearch.of());
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
60
Consider the following pseudocode that returns an Optional value from a method:
if there is a result // line 1
return the result // line 2
else
return an empty result // line 3
Assume that the variable result represents an object reference to the result to be returned as Optional.Replace line 1 with the Java code to determine whether there is a result.
A.if (result.ifPresent())
B.if (result == null)
C.if (result != null)
D.if (result.isPresent())
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
61
Complete the following statement that uses streams to display the names of employees in an ArrayList called employees of Employee objects that have a getName method to return the employee's name as a String. Complete the following statement that uses streams to display the names of employees in an ArrayList called employees of Employee objects that have a getName method to return the employee's name as a String.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
62
Which of the following terminal operations on a generic Stream does NOT return an Optional?
A.anyMatch
B.max
C.findAny
D.findFirst
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
63
Complete the following statement that finds the minimum salary of employees who are Managers.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title. Complete the following statement that finds the minimum salary of employees who are Managers.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title.   A.OptionalInt B.int C.Optional<Integer> D.Integer
A.OptionalInt
B.int
C.Optional
D.Integer
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
64
Which of the following terminal operations does NOT return a result?
A.toArray
B.collect
C.forEach
D.allMatch
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
65
Complete the following statement that finds the average salary of employees who are Database Administrators.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title. Complete the following statement that finds the average salary of employees who are Database Administrators.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.Also, assume the getTitle method returns a String representing the employee's title.   A.Optional<Double> B.OptionalDouble C.double D.Double
A.Optional
B.OptionalDouble
C.double
D.Double
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
66
Complete the following code snippet to display the orderedHonorsMajors stream of alphabetically ordered String objects, representing the unique majors of the students in the honors college. Complete the following code snippet to display the orderedHonorsMajors stream of alphabetically ordered String objects, representing the unique majors of the students in the honors college.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
67
Which of the following terminal operations does NOT return a boolean?
A.anyMatch
B.noneMatch
C.allMatch
D.findAny
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
68
Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
69
Complete the following statement that finds the average salary of employees.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer. Complete the following statement that finds the average salary of employees.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
70
Complete the following statement that uses streams to find the length of the longest employee name.Assume that employeeStream is a stream of Employee objects and the getName method returns a String representing the employee's name. Complete the following statement that uses streams to find the length of the longest employee name.Assume that employeeStream is a stream of Employee objects and the getName method returns a String representing the employee's name.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
71
Complete the following statement that finds the total cost of raising all employee salaries by 10%.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer. Complete the following statement that finds the total cost of raising all employee salaries by 10%.Assume that employeeStream is a stream of Employee objects and the getSalary method returns the employee's salary as an integer.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
72
Which of the following is NOT a correct statement about primitive-type streams?
A.An IntStream is a stream of Integer objects.
B.The methods for streams are also applicable to a primitive-type stream.
C.An IntStream is more efficient than Stream.
D.A primitive-type stream has a sum method.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
73
Complete the following code snippet to determine whether all honors students included in the honorsMajors stream of Student objects have a grade point average of at least 3.0, assuming the method getGpa returns the student's gpa as a double. Complete the following code snippet to determine whether all honors students included in the honorsMajors stream of Student objects have a grade point average of at least 3.0, assuming the method getGpa returns the student's gpa as a double.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
74
Complete the following statement that uses streams to create test data by appending a number to a string. Complete the following statement that uses streams to create test data by appending a number to a string.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
75
Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa. Complete the following code snippet that determines whether there is a Computer Science major with a 4.0 gpa.Assume that studentStream is a stream of Student objects and the getMajor and getName methods return a String representing the student's major and name, respectively.Also assume that the getGpa method returns a double representing the student's gpa.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
76
Which of the following expressions returns an IntStream, assuming that generator is an instance of type Random?
A.generator.int(1,7)
B.generator.nextInts()
C."Hello World".codePoints()
D.Stream.of(1,3,5,7,9)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
77
Which of the following is NOT a terminal operation?
A.count
B.distinct
C.allMatch
D.collect
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
78
Complete the following code snippet to find the highest paid Database Administrator.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer. Complete the following code snippet to find the highest paid Database Administrator.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
79
Complete the following code snippet that determines whether all Managers earn more than 100,000.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer. Complete the following code snippet that determines whether all Managers earn more than 100,000.Assume that employeeStream is a stream of Employee objects and the getTitle method returns a String representing the employee's title.Also assume the getSalary method returns an employee's salary as an integer.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
80
Which of the following is NOT a primitive-type stream?
A.IntStream
B.DoubleStream
C.LongStream
D.FloatStream
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 85 flashcards in this deck.