Java Microservices with Spring Boot and Spring Cloud: Practice Exam, Exams of Technology

A practice exam focused on building scalable java microservices using spring boot and spring cloud. It includes questions covering microservice architecture, spring boot annotations, restful api design, spring cloud components like eureka and openfeign, and resilience patterns like circuit breaker. Each question is followed by a detailed explanation of the correct answer, making it a valuable resource for exam preparation and understanding key concepts in microservices development. The exam covers topics such as configuration management, service discovery, api gateways, and database patterns for microservices.

Typology: Exams

2025/2026

Available from 12/20/2025

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 94

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Building Scalable Java Microservices with
Spring Boot and Spring Cloud Certificate
Practice Exam
**Question 1. Which characteristic best defines a microservice architecture?**
A) Single, monolithic codebase
B) Tight coupling between components
C) Decentralized and autonomous services
D) Shared database for all modules
Answer: C
Explanation: Microservices are designed as independent, looselycoupled services that can be
developed, deployed, and scaled autonomously.
**Question 2. In the TwelveFactor App methodology, which factor deals with storing
configuration in the environment?**
A) Codebase
B) Config
C) Dependencies
D) Build, release, run
Answer: B
Explanation: The “Config” factor states that an app’s config should be stored in environment
variables, keeping it separate from code.
**Question 3. What does the @SpringBootApplication annotation combine?**
A) @Component, @Service, @Repository
B) @Configuration, @EnableAutoConfiguration, @ComponentScan
C) @RestController, @RequestMapping, @ResponseBody
D) @Entity, @Table, @Id
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e

Partial preview of the text

Download Java Microservices with Spring Boot and Spring Cloud: Practice Exam and more Exams Technology in PDF only on Docsity!

Spring Boot and Spring Cloud Certificate

Practice Exam

Question 1. Which characteristic best defines a microservice architecture? A) Single, monolithic codebase B) Tight coupling between components C) Decentralized and autonomous services D) Shared database for all modules Answer: C Explanation: Microservices are designed as independent, loosely‑coupled services that can be developed, deployed, and scaled autonomously. Question 2. In the Twelve‑Factor App methodology, which factor deals with storing configuration in the environment? A) Codebase B) Config C) Dependencies D) Build, release, run Answer: B Explanation: The “Config” factor states that an app’s config should be stored in environment variables, keeping it separate from code. Question 3. What does the @SpringBootApplication annotation combine? A) @Component, @Service, @Repository B) @Configuration, @EnableAutoConfiguration, @ComponentScan C) @RestController, @RequestMapping, @ResponseBody D) @Entity, @Table, @Id

Spring Boot and Spring Cloud Certificate

Practice Exam

Answer: B Explanation: @SpringBootApplication is a convenience annotation that aggregates @Configuration, @EnableAutoConfiguration, and @ComponentScan. Question 4. Which starter would you add to a pom.xml to enable Spring MVC and embedded Tomcat? A) spring-boot-starter-data-jpa B) spring-boot-starter-web C) spring-boot-starter-security D) spring-boot-starter-actuator Answer: B Explanation: spring-boot-starter-web brings in Spring MVC, Jackson, validation, and an embedded servlet container (Tomcat by default). Question 5. How can you activate a specific Spring profile at runtime? A) Setting spring.profiles.active in application.yml B) Adding @EnableProfile annotation C) Using @Profile on the main class D) Changing the package name Answer: A Explanation: The property spring.profiles.active (or a JVM argument) tells Spring which profile(s) to load. Question 6. Which Actuator endpoint provides basic health information of a service? A) /info

Spring Boot and Spring Cloud Certificate

Practice Exam

Question 9. What is the primary purpose of a Data Transfer Object (DTO) in a microservice API? A) Persist data directly to the database B) Encapsulate internal entity structure for external contracts C) Manage transaction boundaries D) Provide logging capabilities Answer: B Explanation: DTOs define the shape of data exposed through APIs, decoupling internal entities from external consumers. Question 10. Which pattern recommends one database per microservice to avoid tight coupling? A) Shared Database pattern B) Database per Service pattern C) Service Registry pattern D) Event Sourcing pattern Answer: B Explanation: The Database per Service pattern enforces service autonomy by giving each service its own data store. Question 11. Which Spring Data interface provides CRUD operations without requiring implementation code? A) CrudRepository B) JpaSpecificationExecutor

Spring Boot and Spring Cloud Certificate

Practice Exam

C) TransactionTemplate D) EntityManager Answer: A Explanation: CrudRepository supplies generic CRUD methods; Spring generates the implementation at runtime. Question 12. When using Spring Data JPA, which annotation marks a method as a custom query using JPQL? A) @Query B) @NamedQuery C) @EntityGraph D) @Modifying Answer: A Explanation: @Query allows definition of JPQL or native SQL queries directly on repository methods. Question 13. Which NoSQL database is best suited for storing key‑value pairs with fast read/write access? A) MongoDB B) Cassandra C) Redis D) Neo4j Answer: C Explanation: Redis is an in‑memory key‑value store optimized for low‑latency operations.

Spring Boot and Spring Cloud Certificate

Practice Exam

Explanation: Choreography relies on event publishing; services listen and act without a central controller. Question 17. Which pattern separates read models from write models to improve scalability? A) Circuit Breaker B) CQRS C) Bulkhead D) Ambassador Answer: B Explanation: Command Query Responsibility Segregation (CQRS) splits commands (writes) from queries (reads). Question 18. What component does Eureka Server provide in a Spring Cloud environment? A) API gateway routing B) Distributed configuration storage C) Service registry and discovery D) Circuit breaker management Answer: C Explanation: Eureka Server maintains a registry of service instances, enabling clients to discover them at runtime. Question 19. How does a Eureka client register itself with the Eureka server? A) By sending a POST request to /register during startup B) Using @EnableDiscoveryClient annotation and configuration properties

Spring Boot and Spring Cloud Certificate

Practice Exam

C) By manually editing the server’s XML file D) Through a RabbitMQ message exchange Answer: B Explanation: @EnableDiscoveryClient (or spring-cloud-starter-netflix-eureka-client) together with proper properties makes the client register automatically. Question 20. Which Spring Cloud component can replace Eureka for service discovery in a Kubernetes environment? A) Consul B) Spring Cloud Config Server C) Spring Cloud Gateway D) Spring Cloud Bus Answer: A Explanation: Consul provides service registration and discovery and integrates with Spring Cloud, suitable for non‑Eureka setups. Question 21. What does the OpenFeign client abstract for developers? A) HTTP client creation, serialization, and load balancing B: Message queue handling C: Database transaction management D: OAuth token generation Answer: A Explanation: OpenFeign generates declarative REST clients, handling HTTP communication, encoding/decoding, and integrates with Ribbon/Eureka for load balancing.

Spring Boot and Spring Cloud Certificate

Practice Exam

Explanation: Filters can manipulate headers, enforce security, perform rate limiting, etc., on inbound/outbound traffic. Question 25. Which library does Spring Cloud Circuit Breaker use by default for resilience? A) Hystrix (deprecated) B) Resilience4j C) Netflix Ribbon D) Apache HttpClient Answer: B Explanation: Spring Cloud Circuit Breaker’s default implementation is based on Resilience4j, offering circuit breaking, rate limiting, and bulkhead patterns. Question 26. What is the purpose of a fallback method in a circuit breaker configuration? A) To retry the failed call indefinitely B) To provide an alternative response when the primary service is unavailable C) To shut down the entire application D) To log the error and rethrow it Answer: B Explanation: A fallback supplies a default or cached response, keeping the system functional during downstream failures. Question 27. Which Spring Cloud Config Server backend is most commonly used for version‑controlled configuration files? A) MySQL database B) Git repository

Spring Boot and Spring Cloud Certificate

Practice Exam

C) Redis cache D) Consul KV store Answer: B Explanation: Config Server can pull property files from a Git repo, allowing versioning and easy rollback. Question 28. How can a microservice refresh its configuration without restarting? A) By calling /actuator/restart endpoint B) By sending a POST to /actuator/refresh (or using Spring Cloud Bus) C) By recompiling the JAR file D) By clearing the application cache manually Answer: B Explanation: The /actuator/refresh endpoint triggers a rebind of @ConfigurationProperties, and Spring Cloud Bus can broadcast refresh events. Question 29. Which library adds trace and span IDs to logs for distributed tracing? A) Micrometer B) Spring Cloud Sleuth C) Logback Classic D) Jackson Answer: B Explanation: Spring Cloud Sleuth instruments Spring applications, inserting trace identifiers into logging contexts. Question 30. Which external system is typically paired with Sleuth to visualize trace data?

Spring Boot and Spring Cloud Certificate

Practice Exam

Question 33. In Spring Security, which filter processes JWT tokens from the Authorization header? A) UsernamePasswordAuthenticationFilter B) JwtAuthenticationFilter (custom) C) BasicAuthenticationFilter D) CsrfFilter Answer: B (custom implementation) Explanation: Spring Security does not provide a built‑in JWT filter; a JwtAuthenticationFilter reads the token, validates it, and sets the security context. Question 34. Which grant type is used by OAuth2 for server‑to‑server communication without user interaction? A) Authorization Code B) Implicit C) Client Credentials D) Resource Owner Password Answer: C Explanation: The client‑credentials grant allows a client to obtain an access token using its own credentials. Question 35. What component in Spring Cloud Gateway can propagate the authenticated user’s JWT to downstream services? A) TokenRelayFilter B) RateLimiterFilter

Spring Boot and Spring Cloud Certificate

Practice Exam

C) CORSFilter D) RewritePathFilter Answer: A Explanation: TokenRelayFilter forwards the incoming token (or a refreshed one) as a header to downstream services. Question 36. Which messaging broker is most suitable for high‑throughput, partitioned event streams? A) RabbitMQ B) ActiveMQ C) Apache Kafka D) Amazon SQS Answer: C Explanation: Kafka’s log‑based, partitioned architecture delivers high throughput and horizontal scalability. Question 37. In Spring Cloud Stream, what abstraction replaces direct broker‑specific APIs? A) MessageChannel B) RabbitTemplate C) KafkaTemplate D) JMSProvider Answer: A Explanation: MessageChannel (and newer functional bindings) abstracts away the underlying broker, allowing code to be broker‑agnostic.

Spring Boot and Spring Cloud Certificate

Practice Exam

Answer: B Explanation: docker build - t . builds an image using the Dockerfile in the working directory. Question 41. In a Dockerfile for a Spring Boot jar, which base image is most lightweight? A) openjdk:11-jdk B) openjdk:11-jre-slim C) openjdk:8-jdk-alpine D) openjdk:17-oracle Answer: C Explanation: The Alpine variant provides a minimal footprint, ideal for containerizing Java applications. Question 42. Which Docker Compose directive defines the order in which services start? A) depends_on B) links C) networks D) volumes Answer: A Explanation: depends_on ensures that a service waits for its dependencies to be started before it begins. Question 43. In Kubernetes, what object represents a set of identical pods and ensures the desired number of replicas? A) Service

Spring Boot and Spring Cloud Certificate

Practice Exam

B) ConfigMap C) Deployment D) Ingress Answer: C Explanation: A Deployment manages ReplicaSets, guaranteeing that a specified number of pod replicas are running. Question 44. Which Kubernetes resource is used to expose a set of pods to external traffic via a stable IP? A) ConfigMap B) Service of type LoadBalancer C) Secret D) PersistentVolumeClaim Answer: B Explanation: A Service of type LoadBalancer (or NodePort) provides a stable endpoint for external clients. Question 45. How does Spring Cloud Kubernetes enable configuration injection? A) By mounting ConfigMaps as files and using @ConfigurationProperties B) By storing properties in a MySQL database C) By using environment variables only D) By hard‑coding values in the source code Answer: A Explanation: ConfigMaps can be mounted as files or exposed as environment variables; Spring Cloud Kubernetes reads them into the application context.

Spring Boot and Spring Cloud Certificate

Practice Exam

D) Cache Answer: C Explanation: Bulkhead limits the number of concurrent calls to a protected resource, preventing resource exhaustion. Question 49. In Spring Cloud Config, what file naming convention allows profile‑specific configuration? A) application‑{profile}.properties B) config‑{profile}.yml C) profile‑application.yml D) properties‑{profile}.json Answer: A Explanation: Spring Boot loads application-{profile}.properties (or .yml) when that profile is active. Question 50. Which actuator endpoint can be used to view the current thread dump? A) /actuator/threaddump B) /actuator/heapdump C) /actuator/loggers D) /actuator/env Answer: A Explanation: /actuator/threaddump provides a snapshot of all JVM threads. Question 51. What does the @Transactional annotation guarantee when applied to a Spring service method?

Spring Boot and Spring Cloud Certificate

Practice Exam

A) The method runs on a separate thread pool B) All database operations inside the method are executed within a single transaction C) The method is exposed as a REST endpoint automatically D) The method’s return value is cached Answer: B Explanation: @Transactional starts a transaction before the method and commits/rolls back based on outcome. Question 52. Which isolation level prevents dirty reads but allows non‑repeatable reads? A) READ_UNCOMMITTED B) READ_COMMITTED C) REPEATABLE_READ D) SERIALIZABLE Answer: B Explanation: READ_COMMITTED ensures only committed data is read, avoiding dirty reads; however, rows can change between reads. Question 53. In a microservice, which pattern is recommended for handling database schema evolution without downtime? A) Drop‑and‑recreate schema on each deployment B) Blue‑Green deployment with feature toggles C) Database migration tools like Flyway or Liquibase with versioned scripts D) Manual SQL scripts executed by DBA only Answer: C