This set of JUnit Multiple Choice Questions & Answers (MCQs) focuses on “Creating HTML Reports”.
1. The Executor implementations provided implement ____________ which is a more extensive interface.
a) ExecutorService
b) ThreadPoolExecutor
c) ArrayDeque
d) SerialExecutor
View Answer
Explanation: The ExecutorService interface is extended and implemented by the Executor implementations.
2. The __________ command executes the given command at some time in the future.
a) Execution()
b) execute(Runnable command)
c) scheduleNext()
d) poll()
View Answer
Explanation: The command may execute in a new thread, in a pooled thread, or in the calling thread.
3. The _____________ exception can be thrown by the execute(Runnable command) function.
a) Arithmetic
b) ArrayIndexOutOfBounds
c) StringIndexOutOfBounds
d) RejectedExecutionException
View Answer
Explanation: RejectedExecutionException is thrown if the task cannot be accepted for execution.
4. Other than RejectedExecutionException, the execute(Runnable command) function can also throw which exception?
a) Arithmetic
b) ArrayIndexOutOfBounds
c) StringIndexOutOfBounds
d) NullPointerException
View Answer
Explanation: This exception is thrown if the command passed as argument is null.
5. ______________ runs all commands that are currently pending.
a) runUntilIdle
b) runPendingCommands
c) execute
d) isIdle
View Answer
Explanation: If those commands also schedule commands for execution, the scheduled commands will not be executed.
6. ____________ runs executed commands until there are no commands pending execution.
a) runUntilIdle
b) runPendingCommands
c) execute
d) isIdle
View Answer
Explanation: runUntilIdle does not tick time forward but just runs executed commands.
7. ____________ returns whether this executor is idle.
a) runUntilIdle
b) runPendingCommands
c) execute
d) isIdle
View Answer
Explanation: isIdle() function checks that there are no pending background tasks waiting to be run.
8. ____________ runs time forwards by a given duration, executing any commands scheduled for execution during that time period.
a) runUntilIdle
b) runPendingCommands
c) tick
d) isIdle
View Answer
Explanation: The tick() command also runs any background tasks spawned by the scheduled tasks.
9. When a call to tick returns, the executor will be idle.
a) True
b) False
View Answer
Explanation: Since the spawned background tasks are run the executor remains idle.
10. ________________ blocks until all tasks have completed execution after a shutdown request, or the timeout occurs.
a) awaitTermination
b) runPendingCommands
c) tick
d) isIdle
View Answer
Explanation: awaitTermination returns true if this executor terminated and false if the timeout elapsed before termination.
Sanfoundry Global Education & Learning Series – JUnit.
To practice all areas of Junit, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Information Technology Internship
- Apply for JUnit Internship
- Buy JUnit Books
- Practice Programming MCQs
- Buy Programming Books