- Java 9 Tutorial
- Java 9 - Home
- Java 9 - Overview
- Java 9 - Environment Setup
- Java 9 - Module System
- Java 9 - REPL (JShell)
- Java 9 - Improved JavaDocs
- Java 9 - Multirelease JAR
- Java 9 - Collection Factory Methods
- Java 9 - Private Interface Methods
- Java 9 - Process API Improvements
- Java 9 - Stream API Improvements
- Try With Resources improvement
- Enhanced @Deprecated Annotation
- Inner Class Diamond Operator
- Optional Class Improvements
- Java 9 - Multiresolution Image API
- CompletableFuture API Improvements
- Java 9 - Miscellaneous Features
- java9 Useful Resources
- Java 9 - Questions and Answers
- Java 9 - Quick Guide
- Java 9 - Useful Resources
- Java 9 - Discussion
Java 9 - Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to Java 9. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is/are introduced in Java 9?
Answer : D
Explanation
All of the above are introduced in Java 9.
Q 2 - What REPL stands for?
Answer : A
Explanation
REPL stands for Read-Eval-Print Loop.
Q 3 - Which of the following method is correct about Set in Java 9?
A - For Set interfaces, of(...) method is overloaded to have 0 to 10 parameters.
B - For Set interfaces, of(...) method is overloaded to have var arg as parameter.
Answer : C
Explanation
Both of the options are correct.
Q 4 - Which of the following is a not valid member of interface till Java 8?
Answer : A
Explanation
Private static method support is added in Java 9.
Q 5 - Which of the following is a correct statement about takeWhile() method of Stream class in Java 9?
A - takeWhile method takes all the values until the predicate returns false.
Answer : C
Explanation
takeWhile method takes all the values until the predicate returns false. It returns, in case of ordered stream, a stream consisting of the longest prefix of elements taken from this stream matching the given predicate.
Q 6 - Which of the following is a correct statement about @Deprecated Annoation?
A - @Deprecated annotation was introduced in java 5 version.
B - Compiler generates warnings whenever a deprecated element is used.
Answer : C
Explanation
Both of the above options are correct.
Q 7 - What is the purpose of Optional Class?
Answer : C
Explanation
Optional Class was introduced in Java 8 to avoid null checks and NullPointerException issues.
Q 8 - Which of the following correctly describes the stream() method of Optional class?
Answer : A
Explanation
If a value is present, it returns a sequential Stream containing only that value, otherwise returns an empty Stream.
Q 9 - Which of the following correctly describes the getResolutionVariants() method of MultiresolutionImage Interface?
Answer : B
Explanation
getResolutionVariants() − Gets a readable list of all resolution variants.
Q 10 - Which of the following correctly describes the newIncompleteFuture() method of CompletableFuture Interface?
B - Returns a new CompletableFuture which is already completed with the given value.
Answer : A
Explanation
newIncompleteFuture() − Returns a new incomplete CompletableFuture of the type to be returned by a CompletionStage method. Subclasses of CompletableFuture class should override this method to return an instance of the same class as this CompletableFuture. The default implementation returns an instance of class CompletableFuture.