Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Java Programming Language Quiz-8

Rating
-
Sold
-
Pages
6
Uploaded on
08-12-2021
Written in
2021/2022

Java Programming Quiz . this quiz will give idea how much do you know about the java programming language. this defiantly help you to boost your knowledge in the field of java. you can use as reference for study.

Institution
Course

Content preview

PROGRAMMING IN JAVA
Assignment6
TYPE OF QUESTION: QUIZ
Number of questions: 10 Total mark: 10 × 1 = 10


QUESTION 1:
Which of the following is NOT a method of the Thread class in Java?

a. isAlive()
b. getPriority()
c. getNames()
d. sleep()

Correct Answer: c

Detailed Solution:

getName() is a method in the pre-defined Java class Thread but not getNames(). Other methods
like isAlive(), getPriority() and sleep() are defined in the Thread class.



QUESTION 2:
Which of the following method can be used to know the priority of a thread?

a. getPriority()
b. priority()
c. isRunning()
d. getThreadPriority()

Correct Answer: a

Detailed Solution:

getPriority() is the method, which is used to know the priority given to a thred.

, QUESTION 3:
Which of the following can be used to create an instance of Thread?

a. By implementing the Runnable interface.
b. By extending the Thread class.
c. By creating a new class named Thread and calling method run().
d. By importing the Thread class from package.

Correct Answer: a, b

Detailed Solution:

An application that creates an instance of Thread must provide the code that will run in that
thread. There are two ways to do this:

 Provide a Runnable object. The Runnable interface defines a single method, run, meant
to contain the code executed in the thread. The Runnable object is passed to the Thread
constructor
 Subclass Thread. The Thread class itself implements Runnable, though its run method
does nothing. An application can subclass Thread, providing its own implementation of
run

Reference:https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html



QUESTION 4:
Which of these keywords must be used to monitor for exceptions?

a. try
b. finally
c. throw
d. catch

Correct Answer: a

Detailed Solution:

A try block must be included in a Java program to make the program robust by handling
exceptions properly.

Written for

Institution
Course

Document information

Uploaded on
December 8, 2021
Number of pages
6
Written in
2021/2022
Type
OTHER
Person
Unknown

Subjects

$7.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vinayakbhatt

Get to know the seller

Seller avatar
vinayakbhatt SGDTP
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions