A task class must implement the ____________ interface. You may create your own
ID: 3919111 • Letter: A
Question
A task class must implement the ____________ interface.
You may create your own custom thread class by extending which of the following classes?
Which Java keyword can be used to create a critical region or an entire method that allows execution by a single thread at a time?
Analyze the following code:
public abstract class Test implements Runnable {
public void doSomething() {
};
}
Analyze the following code:
public class Test implements Runnable {
public static void main(String[] args) {
Thread t = new Thread(this);
t.start();
}
public void run() {
System.out.println("test");
}
}
Explanation / Answer
A task class must implement the __________ mj + __ interface.
Runnable
==================================================
You may create your own custom thread class by extending which of the following classes?
Thread
==========================================================
Which Java keyword can be used to create a critical region or an entire method that allows execution by a single thread at a time?
mutex
=========================================================
Analyze the following code:
public abstract class Test implements Runnable {
public void doSomething() {
};
The class compiles fine.
(a) is wrong because class Test is abstract, (b) is wrong because an abstract class may contain no abstract method. (c) is correct.
========================================
Analyze the following code:
public class Test implements Runnable {
public static void main(String[] args) {
Thread t = new Thread(this);
t.start();
}
public void run() {
System.out.println("test");
}
}
A.The program does not compile because this cannot be referenced in a static method.
===============================================================
hope this will help
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.