Java_Interview_Questions
Java_Interview_Questions
An interface in Java is a reference type that contains only abstract methods (until Java 8) and
Inheritance promotes code reusability. A subclass can inherit the properties and methods of a
Multiple catch blocks allow handling different types of exceptions separately. They are evaluated top
Wrapper classes convert primitive types into objects, allowing them to be used in collections and
with generics.
Deadlock occurs when two threads hold resources and wait for each other indefinitely.
Example:
synchronized (obj1) {
synchronized (obj2) {
// code
// Another thread
synchronized (obj2) {
synchronized (obj1) {
// deadlock risk
Java supports:
- Single
- Multilevel
- Hierarchical
Interface methods must be implemented by classes, so they are public (accessible) and abstract (no
body) by default.
CLASSPATH tells the Java compiler and JVM where to find class files and libraries.
Synchronization ensures that only one thread accesses a critical section (like a method or block) at
Yes. An interface can extend another interface using the extends keyword.
- sleep(): Pauses the thread for a given time. Does not release the lock.
- wait(): Pauses the thread until notify() or notifyAll() is called. It releases the lock.