Core Java
• Differences between HashMap, ConcurrentHashMap, LinkedHashMap, TreeMap
HashMap is not thread-safe. ConcurrentHashMap is thread-safe. LinkedHashMap maintains insertion order.
TreeMap sorts keys.
• Memory management and garbage collection in Java
Java uses automatic garbage collection. Generational GC, G1GC, and ZGC are common collectors.
• final vs finally vs finalize()
final: constant or non-overridable. finally: block always executes. finalize(): called before GC.
• Preventing memory leaks
Avoid static references, close resources, and use weak references when needed.
• Difference between == and .equals()
== checks reference equality. .equals() checks object value equality.
• Shallow copy vs deep copy
Shallow copy copies object references. Deep copy creates new copies of referenced objects.
• Creating immutable classes
Make class final, fields private and final, no setters, and defensive copies of mutable fields.
• Functional interfaces and examples
Single abstract method interfaces. e.g., Runnable, Callable, Comparator, custom @FunctionalInterface.
Multithreading & Concurrency
• synchronized vs Lock interface
synchronized is simpler. Lock provides more control and non-blocking options.
• volatile keyword usage
Ensures visibility of changes to variables across threads.
• Callable, Future, CompletableFuture
Callable returns result. Future retrieves it. CompletableFuture supports chaining.
• Avoiding deadlocks
Use lock ordering, timeout-based locking, and minimal lock holding.
• wait() vs sleep()
wait() releases the lock; sleep() does not.
• When to use ConcurrentHashMap
When multiple threads access and modify map concurrently.
Spring Framework
• Spring Bean lifecycle
Initialization, population, post-processing, destruction.
• Dependency injection in Spring
Constructor, setter, and field injection using @Autowired or @Inject.
• Bean scopes
Singleton, prototype, request, session, etc.
• @Component, @Service, @Repository, @Controller differences
All are stereotypes. @Service for business, @Repository for DAO, @Controller for web.
• Global exception handling
Use @ControllerAdvice with @ExceptionHandler.
• Spring Boot auto-configuration
Spring Boot configures beans based on classpath and properties.
• @Transactional and transaction management
Manages commit/rollback of database operations.
• Securing Spring Boot apps
Use Spring Security, OAuth2, and JWT for authentication/authorization.
REST APIs & Microservices
• REST vs SOAP
REST is lightweight and stateless. SOAP is protocol-based and verbose.
• Idempotent HTTP methods
GET, PUT, DELETE are idempotent; POST is not.
• API versioning strategies
URI versioning, request parameter, header versioning.
• Inter-service communication techniques
REST, gRPC, Kafka, RabbitMQ, Feign clients.
• Spring Cloud Config usage
Centralized configuration server for microservices.
• Fault tolerance (Circuit Breaker, Retry)
Use Resilience4j or Hystrix to handle service failures gracefully.
• Service discovery (Eureka, Consul)
Automatically locate services by name.
• Securing microservices (JWT, OAuth2)
Authenticate and authorize using tokens with Spring Security.
Database (SQL & NoSQL)
• JOIN types: INNER, LEFT, RIGHT
INNER returns common rows. LEFT returns all from left + matched. RIGHT vice versa.
• Optimizing slow SQL queries
Use indexes, avoid SELECT *, and optimize joins.
• Normalization vs denormalization
Normalization avoids redundancy. Denormalization improves performance.
• How indexes work and when to avoid them
Indexes speed up reads, slow down writes. Avoid on frequently updated columns.
• NoSQL experience (MongoDB, Redis)
MongoDB is document-based. Redis is in-memory key-value store.
• Handling distributed transactions (Saga pattern)
Manage transactions across services using local transactions + events.
System Design & Architecture
• Design a URL shortener
Use Base62 encoding, DB for mapping, and cache for speed.
• Scalable file upload service
Use chunked uploads, S3/Blob storage, and message queues.
• Messaging system design patterns
Publisher/subscriber, queue, retry, dead letter queues.
• CQRS and Event Sourcing concepts
Separate reads/writes (CQRS). Persist state as events (event sourcing).
• Large file processing in Java
Use BufferedReader, streaming APIs, and multi-threading.
• Eventual consistency
System reaches consistent state over time, not instantly.
• Monolithic vs microservices architecture
Monolith is one unit. Microservices are independently deployable components.
Testing & DevOps
• Unit testing Spring Boot apps
Use JUnit5, @WebMvcTest, @DataJpaTest.
• Mockito: @Mock, @Spy, @InjectMocks
@Mock creates mock, @Spy partial, @InjectMocks injects into class.
• JUnit5 basics
Annotations like @Test, @BeforeEach, @AfterEach, @Nested.
• CI/CD setup (Jenkins, GitHub Actions)
Automate builds, tests, and deployment pipelines.
• Environment-based config handling
Use Spring profiles and config servers.
Coding & Problem Solving
• Producer-consumer with threads
Use BlockingQueue or synchronized blocks.
• Implementing LRU cache
Use LinkedHashMap with access order.
• Processing CSV files
Use OpenCSV or BufferedReader line-by-line.
• Task scheduler design
Use ScheduledExecutorService or Quartz Scheduler.
Best Practices & Soft Skills
• Handling legacy code
Refactor gradually, add tests, isolate changes.
• Applying SOLID principles
Promotes maintainable, scalable code.
• Code review process
Check logic, performance, readability, and tests.
• Mentoring junior developers
Pair programming, feedback, knowledge sharing.
• Handling production incidents
Quick root cause analysis, rollback plan, communication.
Behavioral Questions
• Optimization of critical systems
Explain profiling, bottlenecks, and implemented solutions.
• Challenging bugs you've solved
Describe symptoms, root cause, and resolution.
• Prioritization under pressure
Mention triaging tasks, communication, and quick wins.
• Leading technical projects
Explain planning, delegation, and delivery experience.