Explain different ways of creating a thread. Which one would you prefer and why?
Answer / Nikhil Nailwal
There are several ways to create a thread in Java: extending Thread class or implementing Runnable interface. Extending the Thread class is more straightforward but can lead to issues with inheritance, while implementing the Runnable interface provides better control and is preferred when dealing with multiple threads.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is flush buffer?
Does garbage collection occur in permanent generation space in jvm?
How do you write a good declaration?
Explain in detail about encapsulation with an example?
How to overcome the exception object reference not set to an instance of object?
Can we rethrow the same exception from catch handler?
How do you create immutable object in java?
what is the need of the Ajax?
What does the string method compareto () do?
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?
Explain about instanceof operator in java?
What happens when main () method is declared as private?