- 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 II
Q 1 - Which of the following method is correct about List in Java 9?
A - For List interfaces, of(...) method is overloaded to have 0 to 10 parameters.
B - For List interfaces, of(...) method is overloaded to have var arg as parameter.
Answer : C
Explanation
Both of the options are correct.
Q 2 - 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 3 - Which of the following method is correct about Map in Java 9?
A - For Map interfaces, of(...) method is overloaded to have 0 to 10 parameters.
B - For Map interfaces, ofEntries(...) method is having 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 7?
Answer : C
Explanation
Default method support is added in Java 8.
Q 5 - Which of the following is a not valid member of interface till Java 7?
Answer : C
Explanation
Static method support is added in Java 8.
Q 6 - Which of the following is a not valid member of interface till Java 8?
Answer : A
Explanation
Private method support is added in Java 9.
Q 7 - 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 8 - 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 9 - Which of the following is a valid member of interface in Java 9?
Answer : C
Explanation
Private static method and private method support is added in Java 9.
Q 10 - Which of the following is a correct statement about Process API in Java 9?
Answer : C
Explanation
In Java 9 Process API which is responsible to control and manage operating system processes has been improved considerably. ProcessHandle Class now provides process's native process ID, start time, accumulated CPU time, arguments, command, user, parent process, and descendants.
Q 11 - Which of the following is a correct statement about Process API in Java 9?
A - ProcessHandle class also provides method to check processes' liveness and to destroy processes.
Answer : C
Explanation
ProcessHandle class also provides method to check processes' liveness and to destroy processes. It has onExit method, the CompletableFuture class can perform action asynchronously when process exits.
Q 12 - 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 13 - Which of the following is a correct statement about dropWhile() method of Stream class in Java 9?
A - dropWhile method throw away all the values at the start until the predicate returns true.
Answer : C
Explanation
dropWhile method throw away all the values at the start until the predicate returns true. It returns, in case of ordered stream, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements matching the given predicate.
Q 14 - Which of the following is a correct statement about iterate() method of Stream class in Java 9?
A - iterate method now has hasNext predicate as parameter.
B - hasNext predicate stops the loop once hasNext predicate returns false.
Answer : C
Explanation
iterate method now has hasNext predicate as paremeter which stops the loop once hasNext predicate returns false.
Q 15 - Which of the following is a correct statement about ofNullable() method of Stream class in Java 9?
Answer : C
Explanation
ofNullable method is introduced to prevent NullPointerExceptions and to avoid null checks for streams. This method returns a sequential Stream containing single element, if non-null, otherwise returns an empty Stream.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | C |
2 | C |
3 | C |
4 | C |
5 | C |
6 | A |
7 | A |
8 | A |
9 | C |
10 | C |
11 | C |
12 | C |
13 | C |
14 | C |
15 | C |
To Continue Learning Please Login
Login with Google