Deck 19: Stream Processing
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/85
العب
ملء الشاشة (f)
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
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
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
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
A.Paths.lines
B.Stream.of
C.Files.lines
D.Files.stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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? 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.iterate
B.of
C.generate
D.stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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();
A.List
B.List
C.List
D.List
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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[]);
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[]);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
A.myStringArrayList.of().count()
B.myStringArrayList.stream().count()
C.myStringArrayList.stream().size()
D.myStringArrayList.stream().length()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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"};
A.Stream
B.Stream
C.Stream
D.Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.collect
B.toArray
C.toList
D.save
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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? 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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});
A.Stream
B.Stream
C.Stream
D.Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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);
Integer[] myArray = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34};
A.Stream
B.Stream
C.Stream
D.Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.collect
B.toArray
C.save
D.toSet
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.save
B.joining
C.toString
D.collect
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
A.Collectors.toArray()
B.Collectors.joining()
C.Collectors.toList()
D.Collectors.toSet()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.toArray
B.save
C.collect
D.values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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"))) { ...};
A.try(Stream
B.try(Stream linesData = Files.lines(Paths.get("data.txt"))) { ...};
C.try(Stream
D.try(Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.filter
B.skip
C.map
D.limit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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())
Stream
________________________________;
A..map(getMajor())
B..filter(s -> s.getMajor())
C..filter(getMajor())
D..map(s -> s.getMajor())
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which method yields a stream of all elements fulfilling a condition?
A.filter
B.limit
C.map
D.skip
A.filter
B.limit
C.map
D.skip
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
try (Stream
{
long dataCount = lineStream
_____________________
.count();
}
A..take(1)
B..filter(1)
C..skip(1)
D..limit(1)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
I generate
II iterate
III random
A.II only
B.I, II, and III
C.I only
D.I and II only
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
List
________________________________
.collect(Collectors.toList());
A..limit(10)
B..count(10)
C..skip(10)
D..filter(10)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.orderby
B.sort
C.order
D.sorted
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.limit
B.distinct
C.skip
D.filter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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%.
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%.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
30
Which method yields a stream obtained by dropping duplicate elements?
A.skip
B.limit
C.filter
D.distinct
A.skip
B.limit
C.filter
D.distinct
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
Stream
________________________________;
A..sort()
B..order()
C..sorted()
D..orderby()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
Stream
________________________________;
A..distinct()
B..skip()
C..filter()
D..unique()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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);
A.Stream
B.Stream
C.Stream
D.Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.filter
B.skip
C.distinct
D.limit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()));
A.Stream
B.Stream
C.Stream
D.Stream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
Stream
________________________________;
A..map(getGpa() >= 3.8)
B..filter(getGpa() >= 3.8)
C..map(s -> s.getGpa() >= 3.8)
D..filter(s -> s.getGpa() >= 3.8)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.parallel
B.terminal
C.non-terminal
D.distributed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.s -> 1 + .10 * s
B.s -> s + .01 * s
C.s -> s * .10
D.s -> s + .10 * s
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
Optional
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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
A.() -> System.out.println(n)
B.() -> System.out.println()
C.n -> System.out.println(n)
D.System.out.println()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
Collections.sort(employees, _____________________________________);
A.Comparator.comparing(Employee::getSalary)
B.Comparator.comparing(Employee::getSalary())
C.Comparator.thenComparing(Employee::getSalary)
D.Comparator.comparing(e -> e.getSalary)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
(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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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()
A.n -> new Student[]
B.n -> new Student[n]
C.() -> new Student[]
D.() -> new Student()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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;
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;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
53
Which of the following is NOT a method for the Optional class?
A.present
B.empty
C.of
D.orElse
A.present
B.empty
C.of
D.orElse
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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);
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
55
Which Java interface is NOT a functional interface?
A.Predicate
B.Comparator
C.Collection
D.ActionListener
A.Predicate
B.Comparator
C.Collection
D.ActionListener
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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");
A.return result.orElse("None");
B.return Optional.empty();
C.return result;
D.return Optional.of("None");
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.p, q -> p * q
B.(p, q) -> p + q
C.(p, q) -> p * q
D.p, q -> p + q
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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());
Optional
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());
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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())
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())
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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
A.anyMatch
B.max
C.findAny
D.findFirst
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
A.OptionalInt
B.int
C.Optional
D.Integer

A.OptionalInt
B.int
C.Optional
D.Integer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
64
Which of the following terminal operations does NOT return a result?
A.toArray
B.collect
C.forEach
D.allMatch
A.toArray
B.collect
C.forEach
D.allMatch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
A.Optional
B.OptionalDouble
C.double
D.Double

A.Optional
B.OptionalDouble
C.double
D.Double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
67
Which of the following terminal operations does NOT return a boolean?
A.anyMatch
B.noneMatch
C.allMatch
D.findAny
A.anyMatch
B.noneMatch
C.allMatch
D.findAny
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
74
Complete the following statement that uses streams to create test data by appending a number to a string. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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)
A.generator.int(1,7)
B.generator.nextInts()
C."Hello World".codePoints()
D.Stream.of(1,3,5,7,9)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
77
Which of the following is NOT a terminal operation?
A.count
B.distinct
C.allMatch
D.collect
A.count
B.distinct
C.allMatch
D.collect
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
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. 

فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck
80
Which of the following is NOT a primitive-type stream?
A.IntStream
B.DoubleStream
C.LongStream
D.FloatStream
A.IntStream
B.DoubleStream
C.LongStream
D.FloatStream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 85 في هذه المجموعة.
فتح الحزمة
k this deck