Read Also: Java 8 Interview Questions and Answers
Java 8 Online Quiz - Multiple Choice Questions and Answers (MCQ)
1. Which statement/statements are correct in regards to Lambda expressionsA. Allow us to process code as data
B. Can be used in a return statement
C. Can be used as a method argument
D. Can be used in a throw statement
The correct answers are A, B, C.
2. Methods in an Interface can be
A. Abstract
B. Final
C. Default
D. Private
The correct answers are A, C.
3. Which of the following can be considered a Functional Interface
A. Serialization
B. Callable
C. Comparable
D. Comparator
E. Runnable
The correct answers are B, C, D, E.
4. Short circuit operations in Java are
A. Reduce
B. Limit
C. Skip
D. NoneMatch
The correct answers are B, D.
5. A Lambda expression returns
A. Object
B. Nothing
C. Function
D. Reference
The correct answer is C.
6. Which of the Stream API operations return a stream itself?
A. Limit
B. Skip
C. FindFirst
D. NoneMatch
The correct answers are A, B, D.
7. Which of the Stream API operations can be performed in parallel?
A. Skip
B. Sorted
C. Filter
D. Distinct
E. Reduce
F. Min
The correct answer is C.
8. Which of the following statement are true in regards to the try-with-resources
A. Any Class which implements Closeable Interface can be used with try-with- resources
B. Any Class which implements AutoCloseable Interface can be used with try-with-resources.
C. FileInputStream fin = new FileInputStream(input); fin.close(); fin.close(); will through Exception
D. It deals with resource leakage.
The correct answers are A, B, D.
9. What are true in regards to Lambda expressions
A. Allows methods to be treated as Objects
B. Allows methods to be treated as primitive values
C. Allows methods to be treated as variables
D. Every Lambda expression denotes an object of a Functional Interface
The correct answers are A, B, C, D.
10. What are correct in regards to the Optional Class.
A. We can extend the Optional Class
B. Get() method throws NoSuchElementException, if no value is present
C. List<Integer> myList = new ArrayList<>();
myList.add(Optionl.empty());
myList.get(0).toString(); // This code will throw an exception.
The correct answers are A, B.
11. Which statement/statements are correct in regards to parallelSort
A. The underlying Array is divided into sub-arrays, and sub-arrays are again further divided into more modular sub-arrays until we have achieved the minimum modularity or minimum level of detail
B. Each sub-array is sorted individually by multiple threads.
C. Parallel sort uses fork/join framework
D. Each sorted sub-array is then merged to arrive at the final sorted Array.
The correct answers are A, B, C, D.
12. Which of the following is a type of Annotation in Java
A. Marker Annotation
B. Closeable Annotation
C. Single Value Annotation
D. Full Annotations
E. Type Annotation
F. Repeating Annotation
The correct answers are A, C, D, E, F.
13. Which statement/statements are correct in regards to Annotations
A. Represents metadata or information attached with Class, methods, or fields
B. Represents metadata or information not attached to Interface
C. JVM or Java compiler can use the information represented by metadata
D. They are not part of Java code.
The correct answers are A, C, D.
14. Which statement/statements are correct in regards to CompletableFuture
A. Get method blocks the current thread until a result is obtained
B. isDone method returns true if the result is ready of false and is a non-blocking operation
C. CompletableFuture is used for asynchronous programming which means writing non-blocking code
D. It runs a task on the main thread.
E. It may be explicitly completed (by setting its value & status).
The correct answers are A, B, C, E.
15. Which statement/statements are correct?
A. Thread Local variables are an alternative to Synchronization
B. An implicit reference to the copy of the Thread Local variable is contained by each thread as long as the thread is alive
C. Each Thread has a stack memory, so any object/instance created via a thread will be part of the stack memory
D. Thread Local objects are stored in Heap memory
The correct answers are A, B, D.
16. What is not true about functional interface in Java?
A. They contains only one abstract method.
B. They exhibit only one functionality.
C. Runnable and Callable are not examples of functional interface.
The correct answer is C.
That's all for today. Please mention in the comments if you have faced any other Java 8 Quiz MCQ question that needs to be added to above list.