21.) In a class that implements multiple interfaces, how is ambiguity resolved if two interfaces provide default methods with the same name?
A) The class must implement both methods explicitly.
B) The compiler throws an error, and the class must choose one method to implement.
C) The class inherits the default method from the first interface it implements.
D) The class inherits the default method from the most specific interface it implements.
22.) What is the primary advantage of the Nashorn JavaScript engine over the older Rhino engine?
A) Improved performance
B) Better support for Java code integration
C) Simpler syntax for JavaScript
D) Enhanced debugging capabilities
23.) Which method in the CompletableFuture class is used to apply a transformation function to the result?
A) thenAccept()
B) thenApply()
C) thenCombine()
D) thenRun()
24.) What is a potential drawback of using parallel streams in Java?
A) Increased complexity of code
B) Limited support for multi-core processors
C) Inefficient use of CPU cores
D) Risk of thread-related issues
25.) Which collector is used to group elements based on a classification function?
A) groupingBy()
B) partitioningBy()
C) mapping()
D) collectingAndThen()
26.) In method references, what does :: denote?
A) Method invocation
B) Method definition
C) Variable assignment
D) Null reference
27.) Which class is used to represent a period of time with both date and time components?
A) LocalDate
B) LocalTime
C) LocalDateTime
D) Period
28.) Can a class override a default method inherited from an interface?
A) Yes, using the override keyword
B) Yes, by providing a new implementation
C) No, it’s not allowed
D) No, default methods are final
29.) What is the purpose of the distinct() intermediate operation in the Streams API?
A) It removes duplicate elements from a stream.
B) It sorts the elements in a stream.
C) It filters elements based on a predicate.
D) It performs a reduction operation.
30.) Which functional interface represents a function that takes two arguments and returns a result?
A) Function
B) BiFunction
C) Consumer
D) Predicate