Thread class, Lifecycle

Thread class, Lifecycle

University

8 Qs

quiz-placeholder

Similar activities

Unit III - Multi

Unit III - Multi

University

13 Qs

thread

thread

University

10 Qs

Online Quiz on Unit-2

Online Quiz on Unit-2

University

10 Qs

JAVA Threads Quiz

JAVA Threads Quiz

University

8 Qs

Thread Priorities

Thread Priorities

University

10 Qs

Quiz on Multithreading

Quiz on Multithreading

University

6 Qs

OS-Multithreading

OS-Multithreading

University

8 Qs

thread

thread

University

9 Qs

Thread class, Lifecycle

Thread class, Lifecycle

Assessment

Quiz

Computers

University

Medium

Created by

Jothi Prakash

Used 2+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are the different states in the lifecycle of a thread?

Paused

Completed

New, Runnable, Blocked, Waiting, Timed Waiting, Terminated

Starting

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the Thread class in Java.

The Thread class in Java is used to perform database operations.

The Thread class in Java is used to create GUI components.

The Thread class in Java is used to create and manage threads.

The Thread class in Java is used to handle exceptions.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the start() method in a thread?

To terminate the thread

To check the status of the thread

To pause the execution of the thread

To begin the execution of the thread

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you create a thread by extending the Thread class?

Inherit from the Runnable interface instead of extending the Thread class.

Use the start() method directly without extending the Thread class.

Create a new class that extends the Thread class and override the run() method.

Create a new class that extends the Runnable interface and implement the run() method.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Discuss the differences between the Thread class and Runnable interface.

The Thread class extends the Thread class itself, while the Runnable interface is implemented by a class to define a thread.

The Thread class can only be used in Java, while the Runnable interface can be used in any programming language.

The Thread class is used for multithreading, while the Runnable interface is used for single-threading.

The Thread class is an abstract class, while the Runnable interface is a concrete class.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default priority of a thread in Java?

1

5

15

10

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the concept of thread priority and how it affects thread scheduling.

Threads with lower priority are scheduled to run before threads with higher priority

Thread priority is determined randomly and does not affect thread scheduling

Thread priority has no impact on thread scheduling

Thread priority is a way to indicate the importance of a thread to the operating system. Threads with higher priority are scheduled to run before threads with lower priority. This affects thread scheduling by allowing the operating system to allocate CPU time to more critical tasks first.

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you change the priority of a thread in Java?

Use the setPriority() method of the Thread class.

Use the changePriority() method of the Thread class.

Access the adjustPriority() method of the Thread class.

Invoke the modifyPriority() method of the Thread class.