Interview Q&A / Java

INTERVIEW Q&A · 72 QUESTIONS

Java interview questions

Collections, the JVM, strings, exceptions and threads, the backbone of most campus placement rounds.

  1. What is the difference between wait() and sleep() in Java?

    sleep() pauses the current thread for a time and keeps any lock it holds. wait() must be called inside a synchronized block, releases that lock, and pauses until notify or notifyAll is called or the timeout ends.

    IntermediateQuick answer1 min read