Interview Questions and Answers
Interview Questions and Answers
A: Checked exceptions are validated at compile time (e.g., IOException), and must be
declared or handled. Unchecked exceptions (e.g., NullPointerException) are not checked
during compilation and usually indicate programming bugs.
Q: How does garbage collection work in Java?
A: Java's garbage collector automatically removes unreachable objects from memory. It uses
algorithms like generational GC, which divides the heap into Young and Old generations for
efficiency.
A: Starters are pre-configured dependencies that simplify project setup. For example,
spring-boot-starter-web bundles dependencies for web applications.
Q: How do you secure a REST API using Spring Security?
A: JPA is a specification, while Hibernate is an implementation. You use JPA annotations like
@Entity, and Hibernate provides additional features like caching and more complex query
support.
Q: What is the N+1 select problem?
A: It occurs when the application fetches an entity and then lazily fetches its related entities
in a loop, causing many SQL queries. It can be resolved using JOIN FETCH or batch fetching.
A: By adding the version in the URL (/api/v1/resource), header versioning, or using media
types (Accept: application/vnd.app.v1+json).
Q: What is a Circuit Breaker pattern?
A: It prevents cascading failures by stopping calls to a failing service for a time. Netflix
Hystrix or Resilience4j can implement it.
A: Maven uses XML for configuration and is declarative, while Gradle uses Groovy/Kotlin
and is more flexible and faster with incremental builds.
Q: How do you resolve Git merge conflicts?
A: By using git status to identify conflicts, editing the conflicting files, then staging (git add)
and committing the resolved state.
A: Docker creates and runs containers; Kubernetes orchestrates and manages those
containers at scale with services like auto-scaling and load balancing.
A: We use Jira for task tracking, participate in daily standups, plan work in Sprint Planning,
and review deliverables in Sprint Review.
Q: Describe a teamwork challenge and how you handled it.
A: In a previous project, a backend and frontend team were misaligned. I proposed a shared
Swagger doc to ensure API clarity, which improved communication and delivery speed.
A: Kafka is distributed and ideal for high-throughput event streaming. RabbitMQ supports
complex routing and message queues. Kafka is log-based; RabbitMQ is queue-based.
Q: How do you ensure message delivery in Kafka?
A: By setting acks=all, enabling retries, and using idempotent producers or consumer offset
management.
A: When you need flexible schemas, horizontal scaling, and store semi-structured or
unstructured data like documents or logs.
Q: What is eventual consistency in Cassandra?
A: Writes are distributed; reads may return stale data temporarily. Tuned using consistency
levels like QUORUM or ONE.
Front-End Knowledge
Q: How do you support front-end teams as a backend developer?
A: By creating well-documented APIs, handling CORS, ensuring fast response times, and
using tools like Swagger or Postman for testing.
DevOps Practices
Q: What does a typical CI/CD pipeline look like for you?
A: Code pushed to Git triggers a Jenkins job, builds via Maven, runs tests, and deploys to
staging using Docker. Ansible may provision infrastructure if needed.