0% found this document useful (0 votes)
3 views3 pages

Java Backend Interview Guide

Uploaded by

06rc09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Java Backend Interview Guide

Uploaded by

06rc09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Backend Interview Questions – Categorized Guide

This document organizes the uploaded interview questions topic-wise with explanatory
answers and practical insights for backend interview preparation.

Core Java
Q: == vs equals()
A: == compares object references (memory addresses), whereas equals() compares object
content. For example, String overrides equals() to compare actual text values.

Q: Internal working of HashMap


A: HashMap stores data in buckets using hashing. A hash code determines the bucket index.
Collisions are handled using LinkedList in older Java versions and balanced trees in Java 8+.

Q: Why load factor is 0.75?


A: 0.75 provides a balance between memory usage and lookup performance. Lower load
factor wastes memory; higher load factor increases collisions.
Q: Java Memory Model
A: Defines how threads interact through memory and guarantees visibility, ordering, and
atomicity.

Q: Thread safety & concurrency


A: Thread safety ensures shared data consistency in multithreaded environments using
synchronization, locks, ConcurrentHashMap, atomic classes, etc.

Java 8
Q: Why Lambda Expressions?
A: Lambdas reduce boilerplate code and enable functional programming in Java.

Q: Streams API
A: Streams process collections declaratively using filter, map, reduce, collect, etc.

Q: Reverse a String using Streams


A: Convert string to stream of chars, reverse using StringBuilder or reduce operation.

Spring Boot
Q: What does @SpringBootApplication consist of?
A: @SpringBootApplication combines @Configuration, @EnableAutoConfiguration, and
@ComponentScan.

Q: Difference between @Component and @Service


A: @Service is a specialized stereotype annotation for service-layer classes, whereas
@Component is generic.

Q: How Spring Boot auto-configuration works internally


A: Spring Boot uses conditional configuration classes loaded from
[Link]/AutoConfiguration imports.

Q: @Transactional and transaction failure


A: @Transactional ensures ACID transactions. On unchecked exceptions, transaction
rollback occurs automatically.

Q: @ControllerAdvice
A: Provides centralized exception handling across controllers.

Microservices
Q: Circuit Breaker Pattern
A: Prevents cascading failures by stopping repeated failed calls temporarily.

Q: Saga Pattern
A: Manages distributed transactions using compensating actions.

Q: Advantages of Microservices
A: Independent deployment, scalability, fault isolation, technology flexibility.
Q: Challenges in Microservices
A: Distributed tracing, data consistency, network latency, service discovery.

Database & SQL


Q: SQL Query Optimization
A: Use indexes, avoid SELECT *, analyze execution plans using EXPLAIN.

Q: How to handle 1M records API


A: Use pagination, streaming, caching, async processing, autoscaling, and sharding.

Security
Q: OAuth vs JWT
A: OAuth is an authorization framework; JWT is a token format.

Q: Can JWT be invalidated?


A: Yes, through token blacklisting, short expiration, or refresh-token rotation.

System Design
Q: Rate Limiter Design
A: Rate limiting can be implemented using Token Bucket or Sliding Window algorithms.

Q: Handling failures between microservices


A: Use retries, circuit breakers, bulkheads, and message queues.

Q: Caching Strategy
A: Redis/in-memory caching reduces database load and improves latency.

Logging & Monitoring


Q: What is Log4j?
A: A Java logging framework used for configurable logging.

Q: What is SLF4J?
A: A logging abstraction that allows plugging different logging frameworks.

Key Preparation Insights


Modern backend interviews focus heavily on production debugging, distributed systems,
Spring Boot internals, database optimization, scalability, resilience, and real-world
architecture discussions.

You might also like