Question
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();
}
}
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();
}
}
Answer: Option C
Was this answer helpful ?
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 ?
Submit Solution