- 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 Mock Test
This section presents you various set of Mock Tests related to Java 9. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Java 9 Mock Test III
Q 1 - Which of the following is a correct statement about try-with-resources statement?
A - The try-with-resources statement is a try statement with one or more resources duly declared.
Answer : D
Explanation
All of the above options are correct.
Q 2 - Which of the following is a correct statement about try-with-resources statement in Java 9?
A - Prior to Java 9, resources are to be declared before try or inside try statment.
Answer : D
Explanation
All of the above options are correct.
Q 3 - Which of the following is a correct statement about try-with-resources statement in Java 9?
A - Prior to Java 9, resources are to be declared before try or inside try statment.
B - In Java 9, resources are not required to be declared before try or inside try statment.
Answer : C
Explanation
Both of the above options are correct.
Q 4 - 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 5 - A program element annotated with @Deprecated means it should not be used for
A - Its usage may leads to errors
Answer : C
Explanation
Both of the above options are correct.
Q 6 - A program element annotated with @Deprecated means it should not be used for
A - It may be removed in future version.
Answer : C
Explanation
Both of the above options are correct.
Q 7 - Which of the following is a correct statement about @Deprecated Annoation?
A - forRemoval indicates whether the annotated element is subject to removal in a future version.
Answer : C
Explanation
Both of the above options are correct.
Q 8 - Which of the following is a correct statement about @Deprecated Annoation?
A - since returns the version in which the annotated element became deprecated.
Answer : C
Explanation
Both of the above options are correct.
Q 9 - In which of the following version of java diamond operator was introduced?
Answer : A
Explanation
Diamond operator was introduced in java 7.
Q 10 - In which of the following version of java diamond operator can be used with anonymous inner classes?
Answer : C
Explanation
In java 9, diamond operator can be used with annonymous class to simplify code and improves readability.
Q 11 - In which of the following version of java Optional Class was introduced?
Answer : B
Explanation
Optional Class was introduced in Java 8 to avoid null checks and NullPointerException issues.
Q 12 - 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 13 - 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 14 - Which of the following correctly describes the ifPresentOrElse() method of Optional class?
Answer : B
Explanation
If a value is present, performs the given action with the value, otherwise performs the given empty-based action.
Q 15 - Which of the following correctly describes the or() method of Optional class?
Answer : C
Explanation
If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | D |
2 | D |
3 | C |
4 | C |
5 | C |
6 | C |
7 | C |
8 | C |
9 | A |
10 | C |
11 | B |
12 | C |
13 | A |
14 | B |
15 | C |
To Continue Learning Please Login
Login with Google