Quiz about Java Quiz Day 46

Java Quiz Day 46

Last Updated :
Discuss
Comments

Question 1

What is the purpose of the Executor framework in Java?

  • A

    To manage thread execution

  • B

    To define thread priorities

  • C

    To perform thread synchronization

  • D

    To manage thread-safe collections

Question 2

What is the main reason a race condition occurs in Java?

  • A

    Multiple threads accessing read-only data

  • B

    Multiple threads accessing shared mutable data without synchronization

  • C

    A single thread performing non-atomic operations

  • D

    Using synchronized blocks

Question 3

What is the output of the unhandled race condition example (expected vs actual)?

  • A

    Always 2000

  • B

    Always less than 2000

  • C

    Sometimes 2000, sometimes less

  • D

    Always 0

Question 4

Which race condition occurs when a thread checks a condition but another thread changes it before the action?

  • A

    Read-Modify-Write Race

  • B

    Initialization Race

  • C

    Check-Then-Act Race

  • D

    Data Visibility Race

Question 5

Which of the following is a key benefit of using the ExecutorService?

  • A

    It automatically synchronizes all tasks

  • B

    It provides better performance by controlling the number of threads

  • C

    It allows only one thread to execute at a time

  • D

    It guarantees the order of task execution

Question 6

What does the Callable interface allow you to do in Java?

  • A

    Return a result from a task

  • B

    Run multiple tasks concurrently

  • C

    Execute a task without returning a result

  • D

    None of these

Question 7

What is a potential consequence of a deadlock in Java?

  • A

    Threads wait indefinitely and do not proceed with execution

  • B

    Threads run faster than usual

  • C

    Threads can execute without interruption

  • D

    Threads are killed automatically

Question 8

Which method is used to submit tasks to an ExecutorService in Java?

  • A

    submit()

  • B

    execute()

  • C

    addTask()

  • D

    run()

Question 9

Which of the following describes a deadlock situation in Java multithreading?

  • A

    When threads are not given enough CPU time

  • B

    When two threads are blocked forever, each waiting for the other

  • C

    When one thread keeps waiting for user input

  • D

    When threads stop responding to external signals

Question 10

Which of the following is true about the Future interface in Java?

  • A

    It allows you to retrieve the result of a task executed by an ExecutorService

  • B

    It is used to manage thread priorities

  • C

    It manages thread synchronization

  • D

    It prevents race conditions

Tags:

There are 13 questions to complete.

Take a part in the ongoing discussion