Java – Client Interview Q&A
1. How does Java memory management work?
Java divides memory into Heap and Stack. Objects are stored in the heap and method calls/variables in the stack. Garbage Collection automatically removes unused objects using algorithms like Mark-and-Sweep and Generational GC, improving memory efficiency.
2. Difference between HashMap and ConcurrentHashMap?
HashMap is not thread-safe and can cause data corruption in multithreaded environments. ConcurrentHashMap is thread-safe and uses segment locking/CAS for better concurrency without blocking the whole map.
3. synchronized vs volatile?
synchronized ensures mutual exclusion and thread safety. volatile ensures visibility of variable changes across threads but does not provide atomicity.
4. What is immutability?
An immutable object cannot change after creation. It improves thread safety. Example: String. To create one: make class final, fields private final, and provide no setters.
5. Runnable vs Callable?
Runnable doesn’t return results or throw checked exceptions. Callable returns a value and can throw exceptions.
6. What is ExecutorService?
ExecutorService manages thread pools and reuses threads, improving performance and resource usage.
7. == vs equals()?
== compares references. equals() compares object content.
8. What is the Java Memory Model?
It defines how threads interact through memory and ensures visibility and ordering of operations.
Spring Boot – Client Interview Q&A
1. What is Spring Boot?
Spring Boot simplifies Spring application development by providing auto-configuration, embedded servers, and starter dependencies.
2. What is auto-configuration?
Spring Boot automatically configures beans based on classpath dependencies and application properties.
3. @Component vs @Service vs @Repository?
All are stereotype annotations. @Service is for business logic, @Repository for data access (adds exception translation), and @Component is generic.
4. How does dependency injection work?
The Spring IoC container creates and injects objects at runtime via constructor or setter injection.
5. What is @Transactional?
It manages transactions automatically. If a runtime exception occurs, the transaction is rolled back.
6. How do you handle global exceptions?
Using @ControllerAdvice and @ExceptionHandler.
7. What is Spring AOP?
Aspect-oriented programming separates cross-cutting concerns like logging and security.
8. How do you secure Spring Boot apps?
Using Spring Security with JWT or OAuth2 authentication.
9. How does Spring Boot manage threads?
It uses embedded server thread pools (such as Tomcat thread pools) to handle requests.
SQL – Client Interview Q&A
1. What are ACID properties?
Atomicity, Consistency, Isolation, and Durability ensure reliable transactions.
2. What is indexing?
Indexes improve query performance by creating a fast lookup structure.
3. INNER JOIN vs LEFT JOIN?
INNER JOIN returns matching rows. LEFT JOIN returns all rows from the left table plus matches.
4. What is normalization?
Normalization organizes data to reduce redundancy and improve integrity.
5. What is a deadlock?
A deadlock occurs when transactions wait for each other indefinitely. It can be prevented using proper locking and transaction ordering.
6. WHERE vs HAVING?
WHERE filters rows before grouping. HAVING filters after aggregation.
7. Query for 2nd highest salary:SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee);
8. What are isolation levels?
Read Uncommitted, Read Committed, Repeatable Read, and Serializable.
AWS – Client Interview Q&A
1. What AWS services have you used?
EC2 (compute), S3 (storage), RDS (database), IAM (security), and CloudWatch (monitoring).
2. What is EC2?
EC2 provides virtual servers in the AWS cloud.
3. What is S3?
S3 is an object storage service for scalable data storage.
4. What is IAM?
Identity and Access Management controls permissions and access to AWS resources.
5. What is auto-scaling?
Auto-scaling automatically adjusts resources based on workload demand.
6. What is a Load Balancer?
A load balancer distributes incoming traffic across multiple servers.
7. What is AWS Lambda?
AWS Lambda is a serverless compute service that runs code without managing servers.
8. How do you deploy Spring Boot on AWS?
Using EC2 instances, Docker containers, or Elastic Beanstalk.
Kafka – Client Interview Q&A
1. What is Kafka?
Kafka is a distributed event streaming platform for real-time data pipelines.
2. What are topics and partitions?
Topics store messages, and partitions enable parallel processing.
3. What is a consumer group?
A consumer group is a set of consumers that share message consumption.
4. How does Kafka ensure durability?
Kafka ensures durability through replication across brokers.
5. Kafka vs RabbitMQ?
Kafka is optimized for high-throughput streaming, while RabbitMQ is suited for complex routing.
6. What is offset?
An offset is a unique identifier for each message within a partition.
7. What is exactly-once delivery?
It ensures messages are processed once using idempotent producers and transactions.
8. How do you scale Kafka?
Kafka is scaled by adding brokers and partitions.