Sail E0 Webinar
Question


What is the output of this program?


class newthread extends Thread {
Thread t;
newthread() {
t = new Thread(this,"New Thread");
t.start();
}
public void run() {
System.out.println(t.isAlive());
}
}
class multithreaded_programing {
public static void main(String args[]) {
new newthread();
}
}
Options:
A .  0
B .  1
C .  true
D .  false
Answer: Option C

 isAlive() method is used to check whether the thread being called is running or not, here 

thread is the main() method which is running till the program is terminated hence it returns

 true.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
true



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers