Basic Java Questions
- What are the main features of Java?
- Explain the difference between
JDK
,JRE
, andJVM
. - What is the difference between
==
and.equals()
in Java? - What are the data types supported by Java?
- Explain the concept of Java memory model.
Object-Oriented Programming (OOP) in Java
- What are the four principles of Object-Oriented Programming?
- What is polymorphism? Provide an example.
- Explain the concept of inheritance in Java.
- What is encapsulation? How is it implemented in Java?
- What is abstraction? How do you achieve it in Java?
Advanced Java Topics
- What are Java collections? Explain the difference between
ArrayList
andLinkedList
. - What is the difference between
HashMap
andTreeMap
? - What are Generics in Java? Why are they used?
- Explain the concept of
HashCode
andequals
method. - What is the significance of the
final
keyword in Java?
Concurrency and Multithreading
- How do you create a thread in Java?
- Explain the difference between
synchronized
andConcurrentHashMap
. - What is a deadlock? How can you prevent it?
- Describe the
ExecutorService
and its benefits. - What are
Callable
andFuture
? How are they used?
Java API and Libraries
- What are the major Java API packages?
- Explain the Java Stream API. Provide an example.
- What is Java NIO? How is it different from the traditional I/O?
- What is the purpose of the
java.lang
package? - How do you handle exceptions in Java? What is the difference between checked and unchecked exceptions?
Design Patterns
- What are design patterns? Name a few commonly used design patterns in Java.
- Explain the Singleton pattern.
- What is the Factory pattern? Provide an example.
- Describe the Observer pattern. How is it implemented in Java?
- What is the difference between
AbstractFactory
andBuilder
pattern?
Performance and Optimization
- How do you optimize the performance of a Java application?
- What is garbage collection in Java? How does it work?
- Explain the concept of JVM tuning.
- What are the common JVM flags used for performance tuning?
- How do you profile a Java application?
Practical Coding Questions
- Write a program to reverse a string in Java.
- How do you find the factorial of a number in Java?
- Write a Java program to check if a given number is prime.
- Implement a thread-safe singleton pattern.
- Write code to merge two sorted arrays.
System Design and Architecture
- How would you design a URL shortening service?
- Explain the architecture of a high-traffic web application.
- How do you design a caching layer in Java?
- Discuss the advantages and disadvantages of microservices architecture.
- How would you design a distributed system with fault tolerance?