Discussion
Sample57 is run - what will be the output?
public class Sample57
{
public static void main(String[] args)
{
System.out.print(Thread.currentThread().isDaemon() + " ");
System.out.print(new Thread().isDaemon());
}
}
Answer: A
Correct answer: false false
The main thread is created by the JVM as a user thread, so the first call prints false. A newly constructed thread inherits its daemon status from the thread that created it, and here that is main - so the second prints false as well. The status is inherited at construction and can be changed with setDaemon, but only before the thread is started.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development