Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA OOP questions, please help, thanks. 1. You can create a thread by passing a

ID: 3763057 • Letter: J

Question

JAVA OOP questions, please help, thanks.

1.

You can create a thread by passing an instance of a Runnable as a parameter to the constructor of a new Thread object.

True

False

2.

Given:

public class DemoRunnable implements Runnable{   
public void run() {   
// some code here   
}
}

3.

Which of the following lines of code is suitable to start a thread ?

new Thread (new DemoRunnable()).start();

new Thread (DemoRunnable.class).start();

new DemoRunnable(new Thread()).run();

new DemoRunnable().start();

What is the data type for the parameter of the version of the Thread sleep() method that accepts a single parameter?

byte

int

number

long

A.

new Thread (new DemoRunnable()).start();

B.

new Thread (DemoRunnable.class).start();

C.

new DemoRunnable(new Thread()).run();

D.

new DemoRunnable().start();

Explanation / Answer

1.False

we cannot simply create a thread by passing an instance of a Runnable as a parameter to the constructor of a new Thread object. we need to implement the runnable interface.

2.