A comprehensive collection of interview questions for Java, Spring Boot, SQL, System Design, and Low-Level Design
1. Core Java
2. Collections
5. Java 8+
9. Spring Boot
- 9.1 Spring Boot Core
- 9.2 Configuration & Properties
- 9.3 Dependency Injection & Beans
- 9.4 REST APIs & Controllers
- 9.5 Exception Handling
- 9.6 Spring Data JPA
- 9.7 Security
- 9.8 Actuator & Monitoring
- 9.9 Testing
- 9.10 Performance & Production
- 9.11 Tricky / Advanced Spring Boot
10. SQL
- 10.1 SQL Basics
- 10.2 Queries & Filtering
- 10.3 Joins
- 10.4 Subqueries & CTEs
- 10.5 Indexing
- 10.6 Normalization & Design
- 10.7 Transactions & ACID
- 10.8 Isolation Levels & Locks
- 10.9 Window Functions
- 10.10 Performance & Optimization
- 10.11 Real-World SQL Problems
- 10.12 Tricky SQL Questions
- 11.1 Core System Design Questions
- 11.2 Storage & Data-Intensive Systems
- 11.3 Scalability & Reliability
- 11.4 Communication & Networking
- 11.5 Consistency, Transactions & Fault Tolerance
- 11.6 Security & Observability
- 12.1 Core OOP & Design Questions
- 12.2 Concurrency-Heavy LLD
- 12.3 Design Patterns
- 12.4 SOLID & Clean Design
-
What is OOP? Explain the four pillars
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
-
What is encapsulation? How do you achieve it in Java?
-
Explain inheritance with real-world example
-
What is polymorphism? Types of polymorphism
- Compile-time (Method Overloading)
- Runtime (Method Overriding)
-
What is abstraction? How is it different from encapsulation?
- Difference between abstract class vs interface (🔥 VERY common)
- When to use abstract class vs interface?
- Can an interface have:
- default methods? (Java 8+)
- static methods? (Java 8+)
- private methods? (Java 9+)
- instance variables?
- Can a class extend multiple classes?
- Can a class implement multiple interfaces?
- What is marker interface? Examples
- What is functional interface? (🔥 Java 8+)
- What is method overloading?
- What is method overriding?
- Difference between overloading vs overriding
- Can we overload main() method?
- Can we override main() method?
- Can we override static methods?
- Can we override private methods?
- Can we override final methods?
- What is method hiding?
- What is covariant return type?
- Explain access modifiers (public, private, protected, default)
- What is final keyword?
- final variable
- final method
- final class
- What is static keyword?
- static variable
- static method
- static block
- What is this keyword?
- What is super keyword?
- Difference between this vs super
- Why Object class is parent of all classes?
- What is equals() method? (🔥 VERY common)
- What is hashCode() method? (🔥 VERY common)
- What is the contract between equals() and hashCode()? (🔥 Critical)
- Difference between == and equals()
- What is toString() method?
- What is clone() method? Deep vs shallow copy
- What is finalize() method? Is it deprecated?
- Why is String immutable in Java? (🔥 VERY common)
- Benefits of String immutability
- What is String pool / String intern pool?
- Difference between String, StringBuilder, StringBuffer
- When to use StringBuilder vs StringBuffer?
- Can we make String mutable?
- What is String.intern() method?
- How many objects created:
String s = new String("hello")? - Difference between
String s = "hello"vsString s = new String("hello")
- What are wrapper classes?
- Why do we need wrapper classes?
- What is autoboxing and unboxing?
- Performance impact of autoboxing
- What is Integer cache?
- Difference between
Integer.valueOf()vsnew Integer()
- Explain JVM architecture (🔥 Important)
- Difference between JDK vs JRE vs JVM
- What is ClassLoader?
- Types of ClassLoaders
- What is class loading process?
- What happens during class loading?
- What is static block execution order?
- What is heap memory?
- What is stack memory?
- Difference between heap vs stack (🔥 VERY common)
- What is PermGen? Why was it removed?
- What is Metaspace? (Java 8+)
- What is Method Area?
- What is String Constant Pool?
- How does Garbage Collection work? (🔥 Important)
- What is minor GC vs major GC?
- What is full GC?
- What is Stop-the-World GC?
- Types of Garbage Collectors
- Serial GC
- Parallel GC
- CMS (Concurrent Mark Sweep)
- G1 GC
- ZGC, Shenandoah
- How to make an object eligible for GC?
- Can we force garbage collection?
- What is memory leak in Java?
- What is OutOfMemoryError?
- Types of OutOfMemoryError
- What is StackOverflowError?
- Difference between OutOfMemoryError vs MemoryLeakError
- How to detect memory leaks?
- JVM tuning parameters (-Xms, -Xmx)
- Strong reference
- Weak reference
- Soft reference
- Phantom reference
- When to use WeakHashMap?
- What is immutable class?
- How to create an immutable class? (🔥 Common)
- Benefits of immutability
- Is String immutable? Why?
- Can we make a class with mutable fields immutable?
- What is defensive copying?
- Examples of immutable classes in Java
- What is Collections Framework?
- Core interfaces in Collections Framework
- Difference between Collection vs Collections
- What is Iterable interface?
- What is Iterator interface?
- What is ListIterator?
- Difference between Iterator vs ListIterator
- What is ArrayList?
- How does ArrayList work internally?
- Initial capacity of ArrayList
- How ArrayList grows dynamically?
- When to use ArrayList?
- What is LinkedList?
- How does LinkedList work internally?
- Difference between ArrayList vs LinkedList (🔥 VERY common)
- When to use LinkedList vs ArrayList?
- What is Vector?
- Difference between ArrayList vs Vector
- Is Vector thread-safe?
- What is Stack class?
- Difference between Array vs ArrayList (🔥 Common)
- Can we change array size after creation?
- How to convert Array to ArrayList?
- How to convert ArrayList to Array?
- What is HashSet?
- How does HashSet work internally? (🔥 Important)
- How HashSet prevents duplicates?
- Can HashSet have null values?
- Is HashSet ordered?
- What is LinkedHashSet?
- Difference between HashSet vs LinkedHashSet
- How LinkedHashSet maintains insertion order?
- What is TreeSet?
- How does TreeSet work internally?
- Difference between HashSet vs TreeSet
- What is NavigableSet?
- Can TreeSet have null values?
- What is HashMap?
- How does HashMap work internally? (🔥 EXTREMELY common - Must know)
- What happens on hash collision? (🔥 Critical)
- Why HashMap size is always power of 2? (🔥 Important)
- What is load factor in HashMap? (Default: 0.75)
- What is threshold in HashMap?
- When does HashMap rehash?
- What changed in HashMap after Java 8? (🔥 Important - Treeify)
- What is treeification in HashMap?
- When does HashMap convert linked list to tree?
- Can we use null key in HashMap?
- Can we use null values in HashMap?
- How many null keys allowed in HashMap?
- Time complexity of HashMap operations
- What is Hashtable?
- Difference between HashMap vs Hashtable (🔥 Common)
- Is Hashtable thread-safe?
- Can Hashtable have null key/values?
- Why Hashtable is legacy?
- What is LinkedHashMap?
- How does LinkedHashMap maintain order?
- Difference between HashMap vs LinkedHashMap
- What is access order in LinkedHashMap?
- How to implement LRU cache using LinkedHashMap?
- What is TreeMap?
- How does TreeMap work internally? (Red-Black Tree)
- Difference between HashMap vs TreeMap
- Can TreeMap have null keys?
- What is NavigableMap?
- What is ConcurrentHashMap? (🔥 VERY important)
- How does ConcurrentHashMap work internally? (🔥 Critical)
- Difference between HashMap vs ConcurrentHashMap
- How ConcurrentHashMap achieves thread-safety?
- What is segment locking? (Java 7)
- What changed in ConcurrentHashMap in Java 8?
- ConcurrentHashMap vs Hashtable vs Collections.synchronizedMap()
- What is WeakHashMap?
- When to use WeakHashMap?
- Difference between HashMap vs WeakHashMap
- What is Queue interface?
- Difference between Queue vs Deque
- What is PriorityQueue?
- How does PriorityQueue work?
- What is ArrayDeque?
- LinkedList vs ArrayDeque
- What is fail-fast iterator? (🔥 Important)
- What is fail-safe iterator?
- Difference between fail-fast vs fail-safe
- Why does ConcurrentModificationException occur? (🔥 Common)
- How to avoid ConcurrentModificationException?
- Which collections are fail-fast?
- Which collections are fail-safe?
- Can we modify collection while iterating?
- What is Comparable interface?
- What is Comparator interface?
- Difference between Comparable vs Comparator (🔥 Common)
- When to use Comparable vs Comparator?
- Can we have multiple Comparators?
- How to sort custom objects?
- What is Collections class?
- Collections.sort() - how it works?
- Collections.synchronizedList() vs CopyOnWriteArrayList
- Collections.unmodifiableList() - use case
- How to create thread-safe collections?
- Difference between synchronized collection vs concurrent collection
- What is a thread?
- What is multithreading?
- Benefits of multithreading
- Difference between process vs thread
- What is main thread in Java?
- Thread lifecycle / states (🔥 Important)
- NEW
- RUNNABLE
- BLOCKED
- WAITING
- TIMED_WAITING
- TERMINATED
- How to create a thread in Java?
- Difference between Thread class vs Runnable interface (🔥 Common)
- Which is better: extending Thread vs implementing Runnable?
- What is Callable interface? (🔥 Java 5+)
- Difference between Runnable vs Callable (🔥 Important)
- What is Future? (🔥 Important)
- What is FutureTask?
- What is CompletableFuture? (🔥 Java 8+)
- Difference between Future vs CompletableFuture
- What is start() method?
- What is run() method?
- Difference between start() vs run() (🔥 Common)
- Can we start a thread twice? (🔥 Tricky)
- What happens if we call run() directly? (🔥 Tricky)
- What is sleep() method?
- What is join() method?
- What is yield() method?
- Difference between sleep() vs wait()
- What is interrupt() method?
- How to stop a thread?
- What is thread safety? (🔥 Important)
- What is race condition?
- What is synchronized keyword? (🔥 VERY important)
- Types of synchronization
- Method level
- Block level
- Static synchronization
- Difference between synchronized method vs synchronized block
- What is object-level lock vs class-level lock?
- Can two threads execute two different synchronized methods?
- What is reentrant synchronization?
- What is wait() method?
- What is notify() method?
- What is notifyAll() method?
- Why wait(), notify() in Object class not Thread? (🔥 Tricky)
- Difference between notify() vs notifyAll()
- Can we call wait() without synchronization?
- What is spurious wakeup?
- What is volatile keyword? (🔥 Important)
- When to use volatile?
- Difference between synchronized vs volatile
- Can volatile guarantee atomicity?
- What is happens-before relationship? (🔥 Important)
- What is Lock interface?
- What is ReentrantLock? (🔥 Important)
- Difference between synchronized vs ReentrantLock (🔥 Common)
- What is fairness policy in locks?
- What is tryLock()?
- What is lockInterruptibly()?
- Benefits of ReentrantLock over synchronized
- What is ReadWriteLock? (🔥 Important)
- When to use ReadWriteLock?
- Difference between ReentrantLock vs ReadWriteLock
- What is Semaphore? (🔥 Important)
- Use cases of Semaphore
- What is CountDownLatch? (🔥 Important)
- What is CyclicBarrier? (🔥 Important)
- Difference between CountDownLatch vs CyclicBarrier (🔥 Common)
- What is Phaser? (Java 7+)
- What is Exchanger?
- What is ExecutorService? (🔥 VERY important)
- What is Executor interface?
- What is Executors utility class?
- Types of thread pools
- FixedThreadPool
- CachedThreadPool
- SingleThreadExecutor
- ScheduledThreadPool
- Difference between FixedThreadPool vs CachedThreadPool (🔥 Common)
- What is ThreadPoolExecutor? (🔥 Important)
- How does ThreadPoolExecutor work internally?
- ThreadPoolExecutor parameters
- corePoolSize
- maximumPoolSize
- keepAliveTime
- workQueue
- threadFactory
- rejectedExecutionHandler
- What are rejection policies?
- What is ScheduledExecutorService?
- How to shutdown ExecutorService?
- Difference between shutdown() vs shutdownNow()
- What are concurrent collections?
- ConcurrentHashMap (🔥 Covered in Collections)
- CopyOnWriteArrayList (🔥 Important)
- CopyOnWriteArraySet
- ConcurrentLinkedQueue
- BlockingQueue interface (🔥 Important)
- Types of BlockingQueue
- ArrayBlockingQueue
- LinkedBlockingQueue
- PriorityBlockingQueue
- SynchronousQueue
- DelayQueue
- When to use BlockingQueue?
- What is deadlock? (🔥 VERY important)
- How to prevent deadlock? (🔥 Important)
- How to detect deadlock?
- What is livelock?
- What is starvation?
- Difference between deadlock vs livelock vs starvation (🔥 Common)
- Implement Producer-Consumer problem (🔥 VERY common)
- Print even/odd using two threads (🔥 Common)
- Print sequence using three threads (🔥 Common)
- Implement thread-safe Singleton (🔥 Important)
- Implement blocking queue
- Implement read-write lock
- What is an exception?
- Exception hierarchy in Java
- Difference between Error vs Exception (🔥 Common)
- What is Throwable class?
- Can we catch Error? (🔥 Tricky)
- Should we catch Error?
- Checked vs Unchecked exceptions (🔥 VERY common)
- Examples of checked exceptions
- Examples of unchecked exceptions
- What is RuntimeException?
- When to use checked vs unchecked exceptions?
- What is try block?
- What is catch block?
- What is finally block? (🔥 Important)
- Will finally block always execute? (🔥 Common)
- When finally block won't execute?
- What is try-with-resources? (🔥 Java 7+)
- What is AutoCloseable interface?
- Can we have try without catch?
- Can we have multiple catch blocks?
- Catch block ordering rules
- What is throw keyword?
- What is throws keyword?
- Difference between throw vs throws (🔥 Common)
- Can we throw checked exception without throws?
- Can we throw multiple exceptions?
- How to create custom exception?
- When to create custom exceptions?
- Should custom exception be checked or unchecked?
- Can a constructor throw exception? (🔥 Common)
- Can we override method and throw broader exception? (🔥 Tricky)
- Exception handling in method overriding
- What happens if exception occurs in finally? (🔥 Tricky)
- What happens if exception in catch block?
- Should we catch Exception or specific exceptions?
- Should we catch Throwable?
- When to use checked exceptions?
- When to use unchecked exceptions?
- Exception handling anti-patterns
- What is lambda expression? (🔥 VERY important)
- Syntax of lambda expression
- Benefits of lambda expressions
- What is functional interface? (🔥 Important)
- @FunctionalInterface annotation
- Can functional interface have multiple methods?
- Built-in functional interfaces
- Predicate
- Function
- Consumer
- Supplier
- BiFunction, BiConsumer, BiPredicate
- What is method reference? (🔥 Important)
- Types of method references
- What is constructor reference?
- What is Stream API? (🔥 VERY important)
- Benefits of Stream API
- Difference between Collection vs Stream
- How to create streams?
- What is stream pipeline?
- Intermediate vs Terminal operations (🔥 Important)
- What is lazy evaluation in streams? (🔥 Important)
- List of intermediate operations
- filter()
- map()
- flatMap()
- distinct()
- sorted()
- peek()
- limit()
- skip()
- List of terminal operations
- forEach()
- collect()
- reduce()
- count()
- anyMatch(), allMatch(), noneMatch()
- findFirst(), findAny()
- min(), max()
- What is map() operation?
- What is flatMap() operation?
- Difference between map() vs flatMap() (🔥 VERY common)
- What is filter() operation?
- What is reduce() operation?
- What is collect() operation?
- What are Collectors?
- Common Collectors methods
- toList(), toSet(), toMap()
- joining()
- groupingBy()
- partitioningBy()
- counting(), summingInt()
- What is parallel stream? (🔥 Important)
- How parallel streams work? (🔥 Important)
- When to use parallel streams?
- When NOT to use parallel streams? (🔥 Important)
- Performance considerations of parallel streams
- What is Optional? (🔥 VERY important)
- Why Optional was introduced?
- How to create Optional objects?
- Optional.of()
- Optional.ofNullable()
- Optional.empty()
- Optional methods
- isPresent()
- ifPresent()
- orElse()
- orElseGet()
- orElseThrow()
- get()
- Why Optional should not be used as field? (🔥 Important)
- Optional best practices
- Optional anti-patterns
- Why new Date-Time API was introduced? (Java 8)
- Problems with java.util.Date
- What is LocalDate?
- What is LocalTime?
- What is LocalDateTime?
- Difference between LocalDate vs Date (🔥 Common)
- What is ZonedDateTime?
- What is ZoneId?
- What is Instant?
- What is Period vs Duration?
- How to parse and format dates?
- What is DateTimeFormatter?
- What are default methods in interface? (🔥 Java 8)
- Why default methods were introduced?
- Can interface have static methods? (🔥 Java 8)
- Can interface have private methods? (Java 9)
- Diamond problem with default methods
- What is forEach() method?
- What is StringJoiner?
- Base64 encoding/decoding
- Nashorn JavaScript engine (Deprecated in Java 11)
- Can we have multiple public classes in a file? (🔥 Tricky)
- Can we execute Java program without main method? (Pre Java 7)
- Can main() method be overloaded? (🔥 Tricky)
- Can we make main() method final, static, synchronized?
- Why is main() method static? (🔥 Tricky)
- Can we declare class as static? (Only nested classes)
- What is static import?
- Can we override static method? (No, method hiding)
- Can constructor be static, final, synchronized, abstract?
- Why wait() is in Object class not Thread? (🔥 VERY tricky)
- Can we start a thread twice? (🔥 Tricky)
- What happens if run() is called directly? (🔥 Tricky)
- Can we call start() method twice on same thread?
- What if both start() and run() are synchronized?
- Why StringBuilder is faster than StringBuffer? (🔥 Common)
- String vs StringBuilder vs StringBuffer - performance
- How many objects:
String s1 = new String("hello");? (2 objects) - What is String.intern() and when to use?
- What happens if hashCode changes after insertion in HashMap? (🔥 VERY tricky)
- Can we make HashMap thread-safe? (Yes, multiple ways)
- How to synchronize HashMap?
- Can we store null in TreeMap? (No for key)
- Can we store null in TreeSet? (No)
- What happens if we put duplicate key in HashMap?
- Can we inherit from multiple classes? (No, Diamond Problem)
- Why multiple inheritance not supported in Java? (🔥 Common)
- Can interface extend multiple interfaces? (Yes)
- Can class implement two interfaces with same method signature?
- What is diamond problem with default methods?
- Can we reduce visibility of inherited method? (No)
- What happens during class loading? (🔥 Important)
- Order of execution: static block, constructor, instance block
- Can we call System.gc()? (Yes, but not guaranteed)
- Does finalize() always execute? (No, deprecated)
- Memory leak scenarios in Java
- How does enum provide singleton? (🔥 Important)
- Can enum implement interface? (Yes)
- Can enum extend class? (No)
- Can we create enum instance using new? (No)
- What is Serialization?
- What is Serializable interface?
- What is serialVersionUID?
- What is transient keyword?
- Can we serialize static variables? (No)
- Difference between Serializable vs Externalizable
- What is deep copy vs shallow copy? (🔥 Common)
- How to create deep copy?
- What is clone() method?
- Why Cloneable is marker interface?
- Problems with clone() method
- Difference between new String("hello") vs "hello"
- Can finally block prevent return? (Yes)
- Can we have try-finally without catch? (Yes)
- What is tight coupling vs loose coupling?
- What is composition vs aggregation?
- Difference between break vs continue vs return
- What is Reflection?
- When to use Reflection?
- How to get Class object?
- How to invoke private method using Reflection?
- Performance impact of Reflection
- Reflection security concerns
- What are annotations?
- Built-in annotations
- @Override
- @Deprecated
- @SuppressWarnings
- @FunctionalInterface
- How to create custom annotation?
- Retention policies (SOURCE, CLASS, RUNTIME)
- Target types (@Target)
- What are Generics? (🔥 Important)
- Benefits of Generics
- Type Erasure in Java
- What are bounded types?
- Difference between
<?>vs<T> - What is wildcard?
- Unbounded wildcard
<?> - Upper bounded
<? extends T> - Lower bounded
<? super T>
- Unbounded wildcard
- PECS principle (Producer Extends, Consumer Super)
- Can we create generic array? (No)
- Singleton pattern (🔥 Thread-safe implementations)
- Factory pattern
- Builder pattern
- Prototype pattern
- Adapter pattern
- Decorator pattern
- Observer pattern
- Strategy pattern
- What is Spring Framework?
- What is Spring IoC? (🔥 Important)
- What is Dependency Injection? (🔥 Important)
- Types of Dependency Injection
- Constructor Injection
- Setter Injection
- Field Injection
- Which DI type is recommended and why? (Constructor)
- What is Spring Bean?
- Bean lifecycle in Spring (🔥 Important)
- Bean scopes
- Singleton (default)
- Prototype
- Request
- Session
- Application
- Difference between Singleton vs Prototype (🔥 Common)
- InitializingBean and DisposableBean
- @PostConstruct and @PreDestroy
- What is AOP? (🔥 Important)
- AOP terminologies
- Aspect
- Join Point
- Advice
- Pointcut
- Weaving
- Types of Advice
- Before
- After
- AfterReturning
- AfterThrowing
- Around
- Use cases of AOP
- What is @Transactional? (🔥 VERY important)
- Propagation types (🔥 Important)
- REQUIRED (default)
- REQUIRES_NEW
- NESTED
- MANDATORY
- SUPPORTS
- NOT_SUPPORTED
- NEVER
- Isolation levels
- DEFAULT
- READ_UNCOMMITTED
- READ_COMMITTED
- REPEATABLE_READ
- SERIALIZABLE
- What happens when @Transactional fails?
- Rollback rules in @Transactional
- Difference between Spring vs Spring Boot (🔥 Common)
- How does Spring Boot auto-configuration work? (🔥 Important)
- What problems Spring Boot solves?
- Spring Boot starter dependencies
- Embedded servers in Spring Boot
- Design a thread-safe cache (🔥 Important)
- How would you implement LRU cache? (🔥 VERY common)
- Design rate limiter (🔥 Important)
- Design connection pool
- Design blocking queue
- How do you handle concurrency at scale? (🔥 Important)
- How would you optimize high-throughput APIs?
- How does ConcurrentHashMap achieve scalability? (🔥 Important)
- Strategies for handling million requests
- Database connection pooling strategies
- SOLID principles
- DRY, KISS, YAGNI
- Code review best practices
- Exception handling best practices
- Logging best practices
- Testing best practices
- What is Spring Boot and why was it introduced?
- Difference between Spring vs Spring Boot
- What problems does Spring Boot solve?
- What is auto-configuration?
- How does Spring Boot auto-configuration work internally?
- What is @SpringBootApplication?
- Explain @Configuration, @EnableAutoConfiguration, @ComponentScan
- What is starter dependency?
- What is embedded server? Why is it used?
- How does Spring Boot decide Tomcat vs Jetty vs Undertow?
- What happens when you run a Spring Boot application?
- What is application.properties vs application.yml?
- How do you define custom properties?
- What is @ConfigurationProperties vs @Value?
- What is profile? (@Profile)
- How do Spring Boot profiles work internally?
- Property precedence order in Spring Boot
- How to override properties at runtime?
- What is externalized configuration?
- What is IoC?
- What is Dependency Injection?
- Difference between @Component, @Service, @Repository
- What is @Autowired? How does it work internally?
- Constructor vs Field vs Setter injection (which is best & why?)
- What is @Primary?
- What is @Qualifier?
- Bean lifecycle in Spring Boot
- What is @Lazy?
- What are bean scopes?
- Difference between @Controller vs @RestController
- What is @RequestMapping?
- Difference between @GetMapping, @PostMapping
- What is @RequestBody?
- What is @RequestParam vs @PathVariable?
- How does Spring Boot convert JSON to Java object?
- What is Jackson?
- How do you handle validation?
- What is @Valid vs @Validated?
- What is @ExceptionHandler?
- What is @ControllerAdvice?
- Global vs local exception handling
- How to return custom error response?
- How to handle validation errors?
- What is ResponseEntity?
- What is Spring Data JPA?
- Difference between JPA vs Hibernate
- What is JpaRepository?
- Difference between CrudRepository, PagingAndSortingRepository, JpaRepository
- How does Spring Boot create repository implementations?
- What is Entity?
- What is Persistence Context?
- What is Lazy vs Eager loading?
- What is N+1 problem?
- How to solve N+1 problem?
- What is @Transactional?
- Propagation types in @Transactional
- Isolation levels
- What happens if exception occurs inside @Transactional?
- What is Spring Security?
- How authentication works in Spring Security?
- What is SecurityFilterChain?
- Difference between authentication vs authorization
- What is JWT?
- How JWT works with Spring Boot?
- Stateless vs Stateful authentication
- What is CSRF?
- How to disable CSRF?
- What is OAuth2?
- Difference between OAuth2 vs JWT
- What is Spring Boot Actuator?
- Important actuator endpoints
- Difference between /health, /info, /metrics
- How do you secure actuator endpoints?
- What is Micrometer?
- Difference between @SpringBootTest vs @WebMvcTest
- What is @MockBean?
- Unit test vs Integration test
- How to test REST APIs?
- What is TestContainers?
- How to test JPA repositories?
- How to improve Spring Boot startup time?
- What is lazy initialization?
- What is connection pooling?
- HikariCP vs others
- How do you handle high traffic?
- How do you make Spring Boot scalable?
- How do you deploy Spring Boot app?
- What is fat jar vs thin jar?
- Why is Spring Boot faster than Spring?
- What happens if two beans have same name?
- How does Spring Boot detect components?
- What is circular dependency?
- How to resolve circular dependency?
- What is ApplicationContext?
- Difference between ApplicationContext vs BeanFactory
- How does Spring Boot handle concurrency?
- What is SQL?
- Difference between SQL vs NoSQL
- What are DDL, DML, DCL, TCL?
- Difference between DELETE vs TRUNCATE vs DROP
- What is PRIMARY KEY?
- Difference between PRIMARY KEY vs UNIQUE
- What is FOREIGN KEY?
- What is NULL?
- What is DEFAULT constraint?
- What is CHECK constraint?
- Difference between WHERE vs HAVING
- Difference between IN vs EXISTS
- Difference between BETWEEN vs >= <=
- What is LIKE?
- What is ORDER BY?
- What is GROUP BY?
- Can we use aggregate functions without GROUP BY?
- What is DISTINCT?
- What is LIMIT / OFFSET?
- How does NULL behave in comparisons?
- Types of joins:
- INNER
- LEFT
- RIGHT
- FULL
- Difference between INNER JOIN vs WHERE
- What is SELF JOIN?
- What is CROSS JOIN?
- What is JOIN vs SUBQUERY?
- What happens if join condition is missing?
- How to find records present in one table but not the other?
- What is subquery?
- Types of subqueries
- What is correlated subquery?
- What is CTE (WITH clause)?
- Difference between CTE vs Subquery
- Recursive CTE – when do we use it?
- What is an index?
- Types of indexes:
- B-Tree
- Hash
- Composite
- Unique
- How does index improve performance?
- When index is not used?
- Downsides of indexing
- What is covering index?
- Difference between clustered vs non-clustered index
- Can a table have multiple clustered indexes?
- How to find slow queries?
- What is normalization?
- 1NF, 2NF, 3NF
- What is denormalization?
- When do we denormalize?
- OLTP vs OLAP
- Fact table vs Dimension table
- Star vs Snowflake schema
- What is a transaction?
- ACID properties
- What is COMMIT?
- What is ROLLBACK?
- What is SAVEPOINT?
- What is auto-commit?
- What is isolation level?
- READ UNCOMMITTED
- READ COMMITTED
- REPEATABLE READ
- SERIALIZABLE
- Dirty Read
- Non-repeatable Read
- Phantom Read
- What is locking?
- Row-level vs Table-level lock
- What is deadlock?
- How databases detect deadlock?
- What are window functions?
- Difference between GROUP BY vs WINDOW function
- What is ROW_NUMBER()?
- RANK() vs DENSE_RANK()
- What is PARTITION BY?
- What is OVER()?
- Running totals using SQL
- Find top N per group
- How do you optimize a slow query?
- What is EXPLAIN / EXPLAIN ANALYZE?
- Difference between INDEX SCAN vs TABLE SCAN
- Why SELECT * is bad?
- How to avoid full table scan?
- What is query caching?
- How pagination works internally?
- OFFSET vs Cursor-based pagination
- Find 2nd highest salary
- Find duplicate records
- Delete duplicates but keep one
- Find employees without manager
- Find consecutive login days
- Running total per user
- Top N salary per department
- Swap two columns
- Find missing IDs
- Update using join
- Count rows per category including zero
- Find max salary per department
- Difference between COUNT(*) vs COUNT(column)
- What happens if GROUP BY column missing?
- Why NULL != NULL?
- UNION vs UNION ALL
- How EXISTS is faster than IN?
- Why indexes slow down INSERT?
- What happens when index is rebuilt?
- Design URL Shortener (TinyURL)
- Design Rate Limiter
- Design Distributed Cache (Redis-like)
- Design Notification System
- Design Chat Application (WhatsApp / Messenger)
- Design News Feed (Facebook / Twitter)
- Design File Storage System (Google Drive / Dropbox)
- Design Search Autocomplete
- Design Logging / Monitoring System
- Design Payment System
- Design Key-Value Store
- Design Distributed Database
- Design Time-Series Database
- Design Event Sourcing System
- Design Leaderboard
- Design Recommendation System
- Design Analytics / Metrics System
- Design Search Engine
- Design Log Aggregation System
- Design Data Warehouse
- What is horizontal vs vertical scaling?
- How do you design for high availability?
- CAP theorem (with examples)
- Consistency models (Strong / Eventual)
- Sharding strategies
- Replication (Leader-Follower, Multi-Leader)
- Load balancing strategies
- Caching strategies (Write-through, Write-back)
- Cache eviction policies (LRU, LFU)
- Handling hot keys
- REST vs gRPC
- HTTP vs WebSockets vs SSE
- Long polling vs polling
- Message queues vs streams
- Kafka vs RabbitMQ
- Exactly-once vs At-least-once delivery
- Idempotency
- API versioning
- Circuit Breaker pattern
- Backpressure
- Distributed transactions
- Two-Phase Commit (2PC)
- Saga pattern
- Eventual consistency
- Quorum reads/writes
- Clock synchronization (NTP, logical clocks)
- Leader election
- Failover strategies
- Retry strategies
- Handling partial failures
- Authentication vs Authorization
- OAuth2 / JWT
- Rate limiting for APIs
- DDoS protection
- Encryption at rest vs in transit
- Secrets management
- Monitoring metrics (RED / USE)
- Logging vs tracing
- Distributed tracing
- Alerting strategies
- Design LRU Cache
- Design Parking Lot
- Design Elevator System
- Design ATM
- Design Library Management System
- Design Movie Ticket Booking System
- Design Chess / Snake & Ladder
- Design File System
- Design Splitwise
- Design Car Rental System
- Design Thread-Safe Cache
- Design Rate Limiter (Token / Leaky Bucket)
- Design Task Scheduler
- Design Producer-Consumer System
- Design Connection Pool
- Design Logger
- Design Thread Pool
- Design Message Queue
- Design Circuit Breaker
- Design Retry Mechanism
- Singleton (thread-safe)
- Factory vs Abstract Factory
- Builder pattern
- Strategy pattern
- Observer pattern
- Decorator pattern
- Adapter pattern
- Proxy pattern
- Chain of Responsibility
- Command pattern
- What is SOLID?
- SRP with real example
- OCP violation examples
- LSP violation examples
- ISP vs fat interfaces
- DIP in real systems
- Composition vs Inheritance
- Favor immutability
- Designing for extensibility
- Designing for testability
Java:
- HashMap internals
- equals & hashCode
- Multithreading basics + locks
- Java memory model
- Java 8 streams
- ConcurrentHashMap
Spring Boot:
- Auto-configuration (internal flow)
- Dependency Injection
- Spring Data JPA + Transactions
- Exception Handling
- Security (JWT flow)
SQL:
- Joins
- Window functions
- Index usage
- Transactions
- Optimization
System Design:
- Requirement clarification
- Trade-offs
- Scalability thinking
- Failure handling
- API + data modeling
LLD:
- Clean class design
- SOLID principles
- Thread safety
- Extensibility
- Correct use of patterns
This document covers the most frequently asked interview questions from top product companies including Amazon, Microsoft, Google, Uber, Flipkart, and various fintech companies.