AmbitionBox

Discover Best Places to work in India

Java Programming

Java Programming Questions and Answers

Showing 11 - 20 of 27 questions

11

What will happen if two thread of same priority are called to be processed simultaneously?

a

Any one will be executed first lexographically

b

Both of them will be executed simultaneously

c

None of them will be executed

d

It is dependent on the operating system.

correct answer d
12

What is the priority of the thread in output of this program?

classmultithreaded_programing{
        publicstaticvoidmain(String args[]){
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }
a

4

b

5

c

0

d

1

correct answer b
13

What is the name of the thread in output of this program?

classmultithreaded_programing{
        publicstaticvoidmain(String args[]){
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }
a

main

b

thread

c

system

d

None of these

correct answer a
14

What is the name of the method used to start a thread execution?

a

init()

b

start()

c

run()

d

resume()

correct answer b
15

In java a thread can be created by ?

a

b

 

c

Both of the above

d

None of these

correct answer c

C is the correct answer.

16

What will be the output of the following program 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

 

 

 

b

The program compiles fine, but it does not print anything because it does not invoke the run() method.

 

c

The program compiles and runs fine and displays test on the console.

d

None of these

correct answer a

A is the correct answer.

17

When a class extends the Thread class ,it should override which method of Thread class to start that thread ?

a

 

start()

 

b

run()

 

c

init()

d

None of these

correct answer b

B is the correct answer.

18

Which method in thread class causes the currently executing thread object to temporarily pause and allow other threads to execute?

a

public boolean isAlive()

b

 public int getId()

c

public void yield()

d

public boolean isDaemon()

correct answer c

Answer:C

 

 

19

In how many states Threads can be explained ?

a

4

b

5

c

3

d

2

correct answer b

Answer:B

20

Which method is used to perform interthread communications?

a

A. yield ( )

b

B. sleep (..)

c

C. notify ( )

d

D. wait ( )

correct answer a
Select a company to compare with

vs

Similar Companies