Java Interview Guide : 200+ Interview Questions and Answers - Thread states, priority, ExecutorService and Callable

Java Interview Guide : 200+ Interview Questions and Answers - Thread states, priority, ExecutorService and Callable

Assessment

Interactive Video

Information Technology (IT), Architecture

University

Hard

Created by

Quizizz Content

FREE Resource

The video tutorial explains the different states of a thread in Java, including new, runnable, running, blocked, and terminated states. It discusses how threads transition between these states and the role of thread priority in CPU allocation. The tutorial introduces the executor service, a modern way to manage thread execution, and highlights its features like future and callable, which allow for task completion checks and result returns.

Read more

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which state is a thread in when it is created but not yet started?

Blocked

Runnable

Running

New

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens when two threads have the same priority?

Both threads run simultaneously

One thread is ignored

The CPU allocates time equally between them

The thread with the lower ID runs first

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default priority assigned to a Java thread?

5

1

10

0

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main purpose of an Executor Service?

To increase thread priority

To manage and execute tasks in the background

To terminate threads

To create new threads

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to check if a task executed by an Executor Service is complete?

checkStatus()

isComplete()

get()

isDone()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a key advantage of using Callable over Runnable?

Callable can return a result

Callable is faster

Callable uses less memory

Callable is easier to implement

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method in the Callable interface is used to return a result?

run()

execute()

call()

start()