Java Interview Questions
Java Interview Questions
An abstract class can have both concrete and abstract methods. It cannot be instantiated directly
and must be extended by another class, which must provide implementations for any abstract
methods.
Generics allow us to use classes and methods with a specific type, providing type safety.
Stack stores method execution and local variables, with each thread having its own stack. Heap
stores objects and is divided into younger and older generations for garbage collection.
4. What is synchronization?
Synchronization is used to restrict access to a variable when multiple threads are involved, ensuring
Annotations define metadata in Java. They help reduce compile-time errors. We can create our own
Design patterns are solutions to common software design problems. They are classified into three
7. What is multithreading?
loose coupling.
A functional interface is an interface with a single abstract method. It can be implemented using
lambdas.
Stream APIs provide a way to process sequences of elements in a functional style, allowing for
The singleton pattern ensures that a class has only one instance and provides a global point of
access to it.
Garbage collection automatically reclaims memory by removing unreferenced objects from memory.
The transient keyword prevents serialization of certain variables, meaning their state will not be
saved.
The volatile keyword ensures visibility of changes to variables across threads, making them visible
to all threads.
A shallow copy copies an object's references, while a deep copy creates a new object and copies all
values.