1. What is Spring Cloud?
AdvancedAnswer: Framework for building microservices and cloud-native apps
Spring Cloud provides tools for building microservices: service discovery, config management, circuit breakers, API gateway, distributed tracing.
24 questions that come up in Spring Boot technical interviews, each with the answer and an explanation of why it is right.
Test yourself — 90 question bankAnswer: Framework for building microservices and cloud-native apps
Spring Cloud provides tools for building microservices: service discovery, config management, circuit breakers, API gateway, distributed tracing.
Answer: Simplifies data access using JPA with repository abstraction
Spring Data JPA simplifies data access layer by providing repository interfaces with automatic implementation. Built on top of JPA (Hibernate).
Answer: Framework that simplifies Spring application development
Spring Boot is an opinionated framework built on top of Spring Framework that simplifies configuration and deployment with auto-configuration and embedded servers.
Answer: Repository interface providing CRUD operations
JpaRepository extends PagingAndSortingRepository, providing CRUD operations, pagination, and batch operations out of the box.
Answer: Service discovery server for microservices
Eureka is service discovery server. Microservices register themselves, discover other services. Part of Netflix OSS, integrated with Spring Cloud.
Answer: Auto-configuration and convention over configuration
Spring Boot provides auto-configuration, starter dependencies, embedded servers, and production-ready features, reducing boilerplate configuration significantly.
Answer: Centralized configuration management for distributed systems
Spring Cloud Config provides centralized configuration management. Config server stores configurations, clients fetch them. Supports Git, SVN, file system.
Answer: @SpringBootApplication
@SpringBootApplication combines @Configuration, @EnableAutoConfiguration, and @ComponentScan. Marks the main entry point class.
Answer: Single entry point for microservices routing requests
API Gateway is single entry point for microservices. Handles routing, authentication, rate limiting, load balancing. Spring Cloud Gateway or Zuul.
Answer: Run main method with SpringApplication.run()
Run the main method containing SpringApplication.run(Application.class, args). Can also use Maven/Gradle plugins or java -jar.
Answer: Prevents cascading failures in distributed systems
Circuit Breaker prevents cascading failures. Stops calling failing service, provides fallback. Use Resilience4j or Netflix Hystrix (deprecated).
Answer: Design pattern where objects receive dependencies from external source
Dependency injection is a design pattern where objects receive their dependencies from an external source (Spring container) rather than creating them.
Answer: Specifies primary key generation strategy
@GeneratedValue specifies primary key generation strategy. Strategies: AUTO, IDENTITY, SEQUENCE, TABLE. Usually AUTO for database-specific strategy.
Answer: Fault tolerance library with circuit breaker, rate limiter
Resilience4j is lightweight fault tolerance library. Provides circuit breaker, rate limiter, retry, bulkhead, time limiter. Modern alternative to Hystrix.
Answer: Framework controls object lifecycle instead of application
IoC is a principle where the framework (Spring) controls the creation and lifecycle of objects, inverting the traditional control flow.
Answer: Repository methods derived from method names
Query methods are repository interface methods where Spring Data generates queries from method names. Example: findByName, findByAgeGreaterThan.
Answer: Traces requests across microservices
Distributed tracing traces requests across microservices. Shows complete request flow, latency. Use Spring Cloud Sleuth with Zipkin or Jaeger.
Answer: IoC container managing beans and their lifecycle
Spring Container (ApplicationContext) is the IoC container that instantiates, configures, and manages beans and their dependencies.
Answer: Authentication and authorization framework
Spring Security provides comprehensive authentication and authorization framework. Handles login, password encoding, role-based access, OAuth2, JWT.
Answer: Adds trace and span IDs to logs for distributed tracing
Spring Cloud Sleuth adds distributed tracing capabilities. Adds trace ID and span ID to logs. Integrates with Zipkin for visualization.
Answer: Object managed by Spring container
A Bean is an object that is instantiated, assembled, and managed by the Spring IoC container. Defined via @Component, @Bean, or XML.
Answer: Stores frequently accessed data to improve performance
Caching stores frequently accessed data in memory to improve performance. Spring supports multiple cache providers: EhCache, Caffeine, Redis, Hazelcast.
Answer: Method-level security checking authorization before execution
@PreAuthorize checks authorization before method execution. Use SpEL expressions: @PreAuthorize("hasRole('ADMIN')"). Requires @EnableGlobalMethodSecurity.
Answer: Marks class as Spring-managed component
@Component marks a class as a Spring-managed component. Spring auto-detects and registers it as a bean during component scanning.
The full Spring Boot bank has 90 questions across 3 difficulty levels — timed, shuffled, and scored.
Take the Spring Boot quiz