-
Q1 EasyWhich of the following feature is introduced in Java 8?ExplanationCorrect option: B) Stream API
-
Q2 EasyWhich of the following is not a core concept of Java 8's new date and time API?ExplanationCorrect option: A) ZonedTime
-
Q3 EasyWhich of these is a new method added to the Collection interface in Java 8?ExplanationCorrect option: A) forEach()
-
Q4 EasyWhat does the Optional class provide in Java 8?ExplanationCorrect option: A) Provides a container that may or may not contain a non-null value
-
Q5 EasyWhich of the following is a functional interface in Java 8?ExplanationCorrect option: D) All of the above
-
Q6 EasyWhat does the lambda expression (String s) -> s.length() return?ExplanationCorrect option: A) A function that takes a string and returns its length
-
Q7 EasyWhich method reference type is used for a static method?ExplanationCorrect option: A) ClassName::staticMethodName
-
Q8 EasyWhich package contains the classes for the new date and time API in Java 8?ExplanationCorrect option: B) java.time
-
Q9 EasyWhat is the main benefit of the Stream API in Java 8?ExplanationCorrect option: A) To allow parallel processing of collections
-
Q10 EasyWhich method is used to filter elements of a stream in Java 8?ExplanationCorrect option: A) filter()
-
Q11 EasyWhich of the following interfaces is not a functional interface?ExplanationCorrect option: D) Serializable
-
Q12 EasyWhich of the following is a method reference to an instance method of a particular object?ExplanationCorrect option: B) objectName::instanceMethodName
-
Q13 EasyHow do you obtain a stream from a collection in Java 8?ExplanationCorrect option: B) collection.stream()
-
Q14 EasyWhich of these is used to represent a value that might be absent?ExplanationCorrect option: B) Optional
-
Q15 EasyWhat is the purpose of the default keyword in an interface?ExplanationCorrect option: B) To provide a default implementation for a method
-
Q16 EasyWhich of these new methods in Java 8 can be used to get the current date?ExplanationCorrect option: A) LocalDate.now()
-
Q17 EasyWhich method is used to create an infinite stream?ExplanationCorrect option: D) Both b and c
-
Q18 EasyWhich of these is a new collector added in Java 8?ExplanationCorrect option: D) All of the above
-
Q19 EasyWhich method in Stream API is used to perform a reduction on the elements of the stream using an associative accumulation function?ExplanationCorrect option: A) reduce()
-
Q20 EasyWhich of the following functional interfaces has a method that accepts a single argument and produces a result?ExplanationCorrect option: C) Function
-
Q21 EasyWhich of the following is not a type of method reference in Java 8?ExplanationCorrect option: D) Enum method reference
-
Q22 EasyWhat is the use of the Stream.of() method?ExplanationCorrect option: A) To create a stream from an array or a list of values
-
Q23 EasyWhich of these methods is used to return the first element of a stream, if present?ExplanationCorrect option: A) findFirst()
-
Q24 EasyWhich of the following is a terminal operation in the Stream API?ExplanationCorrect option: C) forEach()
-
Q25 EasyWhat is the output of Optional.ofNullable(null).isPresent()?ExplanationCorrect option: B) false
-
Q26 EasyWhat is the purpose of the flatMap() method in the Stream API?ExplanationCorrect option: A) To flatten a stream of streams into a single stream
-
Q27 EasyWhich of these is not a new feature in Java 8?ExplanationCorrect option: D) Generics
-
Q28 EasyWhat is the purpose of the Collectors.toMap() method?ExplanationCorrect option: A) To collect elements into a Map
-
Q29 EasyWhich of these methods is used to convert a stream to a list?ExplanationCorrect option: B) collect(Collectors.toList())
-
Q30 EasyWhat is the main purpose of the Supplier functional interface?ExplanationCorrect option: B) To provide a value
-
Q31 EasyWhat does the peek() method do in the Stream API?ExplanationCorrect option: B) Performs an action for each element of the stream and returns the original stream
-
Q32 EasyWhat is the purpose of the Predicate functional interface?ExplanationCorrect option: C) To test elements
-
Q33 EasyWhich method of the Optional class returns the value if present, otherwise throws NoSuchElementException?ExplanationCorrect option: A) get()
-
Q34 EasyHow do you create an empty Optional object?ExplanationCorrect option: A) Optional.empty()
-
Q35 EasyWhich method is used to convert a stream to an array?ExplanationCorrect option: B) toArray()
-
Q36 EasyWhat is the output of Stream.of(1, 2, 3).map(x -> x * 2).collect(Collectors.toList())?ExplanationCorrect option: B) [2, 4, 6]
-
Q37 EasyWhich method of the Stream API is used to sort the elements of a stream?ExplanationCorrect option: A) sorted()
-
Q38 EasyWhat is the purpose of the Function functional interface?ExplanationCorrect option: A) To map a value to another value
-
Q39 EasyWhat does the filter() method do in the Stream API?ExplanationCorrect option: A) Removes elements that match a given predicate
-
Q40 EasyWhich of these methods is used to obtain the count of elements in a stream?ExplanationCorrect option: A) count()
-
Q41 EasyWhich method of the Stream API is used to concatenate two streams?ExplanationCorrect option: A) concat()
-
Q42 EasyWhich functional interface represents an operation that accepts a single input argument and returns no result?ExplanationCorrect option: B) Consumer
-
Q43 EasyWhich of these methods is used to reduce the elements of a stream to a single value?ExplanationCorrect option: A) reduce()
-
Q44 EasyWhat is the purpose of the Collectors.joining() method?ExplanationCorrect option: A) To concatenate the elements of a stream into a single string
-
Q45 EasyWhich method in the Stream API is used to remove duplicate elements?ExplanationCorrect option: A) distinct()
-
Q46 EasyWhich of the following is a method of the Optional class to provide an alternative value if the original value is not present?ExplanationCorrect option: A) orElse()
-
Q47 EasyWhat is the purpose of the Collectors.groupingBy() method?ExplanationCorrect option: A) To group the elements of a stream by a classifier function
-
Q48 EasyWhich method in the Stream API is used to create a parallel stream?ExplanationCorrect option: B) parallelStream()
-
Q49 EasyWhich of these methods is used to return an Optional describing the specified value, if non-null, otherwise returns an empty Optional?ExplanationCorrect option: A) ofNullable()
-
Q50 EasyWhich method is used to check if a value is present in an Optional?ExplanationCorrect option: A) isPresent()