Java Spring Framework Cloud Services Certification Practice Exam, Exams of Technology

A practice exam for the 'building cloud services with the java spring framework' certification. It includes multiple-choice questions covering key concepts such as http methods, restful api design, spring annotations, spring boot configurations, and jpa entities. Each question is followed by a detailed explanation of the correct answer, making it a valuable resource for exam preparation and understanding the fundamentals of cloud service development with java spring. The practice exam covers essential topics for developers aiming to build robust and scalable cloud applications using the java spring framework. It tests knowledge of restful apis, spring mvc, and data persistence with jpa.

Typology: Exams

2025/2026

Available from 12/20/2025

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

4.2

(5)

29K documents

1 / 91

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Building Cloud Services with the Java Spring
Framework Certificate Practice Exam
Question 1. **Which HTTP method is defined as safe and idempotent, and should not change
server state?**
A) POST
B) PUT
C) GET
D) PATCH
Answer: C
Explanation: GET is considered safe because it only retrieves data without sideeffects, and it is
idempotent because multiple identical requests yield the same result.
Question 2. **In a RESTful API, which HTTP status code best indicates that a request has been
fulfilled and resulted in a new resource being created?**
A) 200 OK
B) 201 Created
C) 202 Accepted
D) 204 No Content
Answer: B
Explanation: 201 Created signals that the request succeeded and a new resource was created,
often returning a Location header with the URI of the new resource.
Question 3. **Which header is used by a client to tell the server what media types it can
understand in the response?**
A) Content-Type
B) Accept
C) Authorization
D) Cache-Control
Answer: B
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

Partial preview of the text

Download Java Spring Framework Cloud Services Certification Practice Exam and more Exams Technology in PDF only on Docsity!

Framework Certificate Practice Exam

Question 1. Which HTTP method is defined as safe and idempotent, and should not change server state? A) POST B) PUT C) GET D) PATCH Answer: C Explanation: GET is considered safe because it only retrieves data without side‑effects, and it is idempotent because multiple identical requests yield the same result. Question 2. In a RESTful API, which HTTP status code best indicates that a request has been fulfilled and resulted in a new resource being created? A) 200 OK B) 201 Created C) 202 Accepted D) 204 No Content Answer: B Explanation: 201 Created signals that the request succeeded and a new resource was created, often returning a Location header with the URI of the new resource. Question 3. Which header is used by a client to tell the server what media types it can understand in the response? A) Content-Type B) Accept C) Authorization D) Cache-Control Answer: B

Framework Certificate Practice Exam

Explanation: The Accept header lists the MIME types the client is willing to accept; the server uses it for content negotiation. Question 4. When designing a URL for a collection of books, which of the following follows REST best practices? A) /getBooks B) /books/list C) /books D) /books?action=read Answer: C Explanation: REST recommends noun‑based resource URLs; “/books” represents the collection and can be used with different HTTP verbs. Question 5. Which Spring annotation marks a class as a candidate for auto‑detection and registers it as a bean in the application context? A) @Autowired B) @Component C) @Service D) @Repository Answer: B Explanation: @Component is a generic stereotype that indicates the class should be discovered during component scanning and instantiated as a bean. Question 6. If multiple beans of type PaymentService exist, how can you tell Spring which one to inject into a dependent component? A) Use @Primary on the desired bean B) Use @Qualifier on the injection point

Framework Certificate Practice Exam

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 aggregates MVC, JSON handling (Jackson), and the default servlet container (Tomcat). Question 10. Where does Spring Boot look for external configuration properties by default? A) application.yml only B) application.properties only C) Both application.properties and application.yml (YAML takes precedence if both exist) D) environment variables only Answer: C Explanation: Spring Boot loads properties from both files; if both are present, properties in application.yml override those in application.properties. Question 11. How can you activate a Spring profile named “prod” when launching a Spring Boot application? A) Set spring.profiles.active=prod in application.properties B) Use – Dspring.profiles.active=prod JVM argument C) Add @Profile("prod") on a configuration class D) Both A and B are valid ways Answer: D Explanation: Profiles can be activated via property files or JVM system properties; both approaches set the active profile to “prod”.

Framework Certificate Practice Exam

Question 12. Which Actuator endpoint provides basic health information about the application (e.g., up/down status)? A) /info B) /metrics C) /health D) /env Answer: C Explanation: The /health endpoint reports the overall health status, aggregating checks from various components. Question 13. What does the @Configuration annotation indicate in a Spring Java‑based configuration class? A) The class is a bean definition source B) The class should be scanned for @Component C) The class will be instantiated as a prototype bean D) None of the above Answer: A Explanation: @Configuration marks the class as containing @Bean methods that define beans for the application context. Question 14. Which annotation should you place on a method inside a @Configuration class to expose a bean of type DataSource? A) @Component B) @Bean C) @Service D) @Autowired

Framework Certificate Practice Exam

B) @RequestParam("page") C) @RequestBody("page") D) @ModelAttribute("page") Answer: B Explanation: @RequestParam extracts query parameters (or form fields) from the request URL. Question 18. When a Spring MVC method parameter is annotated with @RequestBody, what does Spring do with the incoming HTTP payload? A) It binds form fields to the object B) It reads the request body and converts it using HttpMessageConverters (e.g., Jackson) C) It extracts the value from a path variable D) It validates the parameter only Answer: B Explanation: @RequestBody triggers deserialization of the request body into the target object using configured converters. Question 19. Which Spring annotation enables automatic validation of a method argument annotated with @Valid? A) @Validated on the controller class B) @EnableValidation on the configuration class C) @Validate on the method D) No additional annotation is required; @Valid alone works if a validator is on the classpath Answer: D Explanation: When Bean Validation API (e.g., Hibernate Validator) is present, @Valid triggers validation; @Validated is used for group validation but not mandatory.

Framework Certificate Practice Exam

Question 20. How can you globally handle all exceptions thrown by any @RestController in a Spring Boot application? A) Define a method annotated with @ExceptionHandler inside each controller B) Create a class annotated with @ControllerAdvice and include @ExceptionHandler methods C) Use a try‑catch block in every endpoint method D) Configure a custom error page in application.properties Answer: B Explanation: @ControllerAdvice applies across all controllers, allowing centralized exception handling. Question 21. Which interface provides CRUD operations for a JPA entity without requiring any method implementation? A) CrudRepository B) JpaRepository C) PagingAndSortingRepository D) All of the above (they extend each other) Answer: D Explanation: JpaRepository extends PagingAndSortingRepository, which extends CrudRepository; all inherit default CRUD methods. Question 22. Given an entity User with a field email, which derived query method name will retrieve a user by email address? A) findByEmail(String email) B) getUserByEmail(String email) C) retrieveByEmail(String email) D) queryByEmail(String email) Answer: A

Framework Certificate Practice Exam

D) Neither; a join table is always used Answer: B Explanation: The many side contains the foreign key referencing the one side; the owning side is the side with the foreign key. Question 26. Which Spring Data annotation allows you to write a custom JPQL query directly on a repository method? A) @NamedQuery B) @Query C) @CustomQuery D) @SqlResultSetMapping Answer: B Explanation: @Query lets you specify JPQL or native SQL for a repository method, overriding derived query generation. Question 27. How does Spring Data REST expose a JPA repository as a REST endpoint? A) By automatically creating a controller for each repository B) By generating OpenAPI documentation only C) By requiring you to write @RestController methods manually D) It does not expose repositories; it only provides CRUD services internally Answer: A Explanation: Spring Data REST scans for Repository interfaces and creates RESTful endpoints (e.g., /people) with HATEOAS links. Question 28. Which HTTP header does Spring Data REST use to provide pagination links? A) Link

Framework Certificate Practice Exam

B) X-Pagination C) Pagination-Info D) Content-Range Answer: A Explanation: The standard “Link” header contains rel=”next”, rel=”prev”, etc., for pagination. Question 29. What does the @Transactional annotation do when placed on a service method? A) It opens a new database connection for each call B) It starts a transaction before method execution and commits/rolls back after completion C) It caches the method result in the second‑level cache D) It disables lazy loading for JPA entities inside the method Answer: B Explanation: @Transactional demarcates a transaction boundary; Spring begins a transaction, then commits on success or rolls back on unchecked exceptions. Question 30. If a method annotated with @Transactional throws a checked exception that is not a subclass of RuntimeException, what is the default rollback behavior? A) The transaction is always rolled back B) The transaction is committed (no rollback) C) The transaction is rolled back only if the exception is annotated with @Rollback D) Spring rolls back for any exception by default Answer: B Explanation: By default, Spring rolls back only on unchecked (RuntimeException) and Error; checked exceptions cause a commit unless configured otherwise.

Framework Certificate Practice Exam

Explanation: AuthenticationManager processes authentication requests, delegating to providers that check credentials. Question 34. In Spring Security, which annotation can be placed on a controller method to require that the caller be authenticated and have the role “ADMIN”? A) @RolesAllowed("ADMIN") B) @PreAuthorize("hasRole('ADMIN')") C) @Secured("ROLE_ADMIN") D) All of the above (each works with proper configuration) Answer: D Explanation: All three annotations can enforce role‑based access; @PreAuthorize uses SpEL, @Secured checks simple role names, and @RolesAllowed follows JSR‑250. Question 35. What is the default password encoding mechanism used by Spring Security’s PasswordEncoderFactories.createDelegatingPasswordEncoder()? A) No encoding (plain text) B) BCrypt C) SHA‑ 256 D) PBKDF Answer: B Explanation: The delegating encoder defaults to BCrypt, providing a strong hashing algorithm. Question 36. Which filter in Spring Security is responsible for handling HTTP Basic authentication? A) UsernamePasswordAuthenticationFilter B) BasicAuthenticationFilter C) BearerTokenAuthenticationFilter

Framework Certificate Practice Exam

D) JwtAuthenticationFilter Answer: B Explanation: BasicAuthenticationFilter processes the Authorization header for HTTP Basic credentials. Question 37. When configuring CORS in a Spring Boot application, which annotation can be used directly on a controller method to allow requests from any origin? A) @CrossOrigin(origins = "") B) @AllowOrigin("") C) @CorsMapping("") D) @EnableCors("") Answer: A Explanation: @CrossOrigin configures CORS per controller or method; origins="*" permits any domain. Question 38. Which actuator endpoint provides information about the JVM’s memory usage? A) /metrics/jvm.memory.used B) /heapdump C) /env D) /info Answer: A Explanation: The /metrics endpoint exposes various JVM metrics; the specific metric for used memory is jvm.memory.used. Question 39. In Spring Boot, what property disables the auto‑configuration of the DataSource bean?

Framework Certificate Practice Exam

Explanation: @EnableCaching turns on the processing of cache‑related annotations like @Cacheable, @CachePut, and @CacheEvict. Question 42. Which annotation can be placed on a method to indicate that its result should be cached with a key derived from method parameters? A) @Cacheable B) @CachePut C) @CacheEvict D) @CacheResult Answer: A Explanation: @Cacheable caches the method’s return value; the key is generated from parameters unless a custom key is defined. Question 43. When using Spring’s RestTemplate to perform a POST request with a JSON body, which method signature is most appropriate? A) postForObject(String url, Object request, Class responseType) B) postForEntity(String url, Object request, Class responseType) C) exchange(String url, HttpMethod.POST, HttpEntity<?> requestEntity, Class responseType) D) Any of the above can be used; they differ in the type of response wrapper Answer: D Explanation: All three methods support POST with a JSON payload; postForObject returns the body directly, postForEntity returns a ResponseEntity, and exchange offers full control. Question 44. Which annotation on a Spring bean method tells the container to produce a new instance each time the bean is requested? A) @Scope("prototype") B) @Prototype

Framework Certificate Practice Exam

C) @Singleton D) @RequestScope Answer: A Explanation: @Scope("prototype") changes the bean’s lifecycle from the default singleton to a new instance per request. Question 45. In a Spring Cloud application, which component is responsible for service discovery using Netflix Eureka? A) @EnableEurekaClient B) @EnableDiscoveryClient C) Both A and B (they are equivalent when Eureka is on the classpath) D) @EnableCircuitBreaker Answer: C Explanation: When Eureka client libraries are present, both annotations enable discovery; @EnableDiscoveryClient is generic, while @EnableEurekaClient is Eureka‑specific. Question 46. Which Spring Cloud annotation enables client‑side load‑balanced REST calls using Ribbon? A) @LoadBalanced on a RestTemplate bean definition B) @RibbonClient on a configuration class C) @FeignClient on an interface D) @EnableLoadBalancing Answer: A Explanation: Declaring a RestTemplate bean with @LoadBalanced injects a Ribbon‑backed interceptor that resolves service names to instances. Question 47. What is the primary benefit of using Spring Cloud Config Server?

Framework Certificate Practice Exam

Question 50. Which of the following is NOT a valid Spring Boot actuator endpoint exposure method? A) management.endpoints.web.exposure.include=* B) management.endpoints.web.exposure.exclude=health,info C) spring.boot.actuator.enabled=true D) Adding the actuator dependency and configuring exposure via properties Answer: C Explanation: There is no property named spring.boot.actuator.enabled; actuator endpoints are enabled by default when the dependency is on the classpath. Question 51. What does the @JsonIgnore annotation do when placed on a field of a Spring MVC response object? A) Prevents the field from being deserialized from incoming JSON B) Excludes the field from JSON serialization in the response body C) Marks the field as required during validation D) Renames the field in the generated JSON output Answer: B Explanation: @JsonIgnore tells Jackson to skip the annotated property when converting the object to JSON. Question 52. Which HTTP status code should a Spring MVC controller return when a requested resource is not found? A) 200 OK B) 400 Bad Request C) 404 Not Found D) 500 Internal Server Error

Framework Certificate Practice Exam

Answer: C Explanation: 404 indicates that the server cannot find the requested resource. Question 53. When using @RequestMapping at the class level with value="/api", and a method annotated with @GetMapping("/users"), what is the full path for the endpoint? A) /users B) /api/users C) /api/get/users D) /api/users/get Answer: B Explanation: Class‑level mapping prefixes all method‑level mappings, resulting in /api/users. Question 54. Which annotation can be used to map a method parameter to a part of the URL path in Spring MVC? A) @RequestParam B) @PathVariable C) @RequestHeader D) @ModelAttribute Answer: B Explanation: @PathVariable extracts values from URI template placeholders. Question 55. In a Spring Boot application, how can you externalize a secret key without hard‑coding it in application.properties? A) Store it in the source code as a static final variable B) Use an environment variable and reference it with ${MY_SECRET} in the properties file C) Place it in a comment inside application.yml