Interview Q&A / Java
Java interview questions
Collections, the JVM, strings, exceptions and threads, the backbone of most campus placement rounds.
Prefer rapid revision? Practise Java short interview answers →
- Should you extend Thread or implement Runnable in Java?
Implement Runnable in most cases. It separates the task from the thread, leaves your class free to extend something else, and works with thread pools. Extending Thread only makes sense if you are changing the thread behaviour itself.
BeginnerQuick answer1 min read - What happens if you call run() instead of start() on a Java thread?
start() creates a new thread of execution and calls run() on it. Calling run() directly is an ordinary method call on the current thread, so no concurrency happens. Calling start() twice throws IllegalThreadStateException.
BeginnerQuick answer1 min read