Limited-Time Offer: Enjoy 50% Savings! Coupon code: 50OFF Use it at checkout
Skip to content

Free VMware Professional Develop VMware Spring 2V0-72.22 Exam Questions

Last updated: · 14 practice questions with answers and explanations

Page: 1 / 8 Total 79 questions

Want more questions? Get Premium Access.

Question 1

New Single answer

Topic: Spring Core

Skill tested: Configure Java-based beans with explicit dependencies and retrieve them from an application context.

A service is being split into Java configuration classes. `OrderService` requires an `InventoryClient`, and both beans must be managed by Spring. The application already loads `OrderConfiguration` through an `AnnotationConfigApplicationContext`; the team wants to keep construction explicit and avoid component scanning because only a small, reviewed set of types may be registered. Which change best satisfies the requirement?

Correct Answer: B. Declare both beans with `@Bean` methods, have the `OrderService` factory method accept `InventoryClient`, and retrieve `OrderService` by type from the context.
Explanation:

Declaring both objects with `@Bean` methods keeps registration explicit, while a factory-method parameter lets Spring resolve and inject the `InventoryClient` bean. The context can then supply the managed `OrderService` by type. Component scanning in A violates the requirement to register only an explicitly reviewed set of types. C creates the client outside Spring management, which prevents independent configuration and lifecycle management. A shutdown hook in D manages context shutdown; it does not register ordinary objects as beans.

Question 2

New Single answer

Topic: Spring Core

Skill tested: Select bean scopes that match shared service and per-request state requirements.

A Spring web application has a stateless pricing engine used concurrently by all customers and a request-specific object that accumulates validation messages during one HTTP request. The application must not leak one request's messages into another, and the pricing engine should not be recreated for every request. Which scope design is most appropriate?

Correct Answer: B. Make the pricing engine singleton-scoped and the validation object request-scoped.
Explanation:

A singleton is appropriate for a stateless, thread-safe pricing engine because one shared instance can serve concurrent requests without retaining user-specific state. A request-scoped validation object is created for the active web request, preventing validation messages from crossing request boundaries. Making both singletons, as in A, risks shared mutable state and depends on every caller clearing it correctly. B needlessly recreates the stateless engine. D shares the per-request data and creates the pricing engine more often than necessary.

Question 3

New Multiple answers

Topic: Spring Core

Skill tested: Apply externalized properties, active profiles, and SpEL to control Spring configuration.

A deployment has a default database connection pool configuration and a production-specific maximum pool size. The production value must come from an external property source, while a production-only audit component must not be registered in development. In addition, a bean needs to derive a display label from another bean's property using Spring Expression Language. Which three configuration choices meet these requirements? Select THREE.

Correct Answer: B. Use `@Profile("production")` on the audit component and activate the `production` profile in production.; C. Use a SpEL expression such as `#{@systemSettings.displayName}` for the derived label.; D. Bind the pool settings from externalized configuration using `@ConfigurationProperties` or property placeholders.
Explanation:

Externalized configuration lets deployment-specific pool values change without recompiling; `@ConfigurationProperties` is particularly suitable for grouped settings. Profiles select environment-specific bean definitions, so activating `production` registers the production-only audit component. SpEL can reference a bean property through the application context. A hard-coded value in D is not an external production setting, and profiles do not replace compiled constants. `@ConditionalOnMissingBean` concerns bean presence, not the active profile, so E does not implement the stated environment rule.

Question 4

New Single answer

Topic: Spring Core

Skill tested: Distinguish BeanFactoryPostProcessor and BeanPostProcessor lifecycle responsibilities.

A platform team needs to adjust a bean definition's property value before Spring creates the bean, based on deployment configuration. The team also wants to wrap selected created service instances with a proxy after initialization. It must use the Spring extension points intended for these different lifecycle stages. Which design is correct?

Correct Answer: C. Use a `BeanFactoryPostProcessor` to modify bean definitions before bean creation and a `BeanPostProcessor` to process instances around initialization.
Explanation:

A `BeanFactoryPostProcessor` works with the bean factory's metadata and can change bean definitions before ordinary beans are instantiated. A `BeanPostProcessor` receives bean instances during creation and can return a wrapped instance, including a proxy, around initialization callbacks. A reverses the responsibilities of these extension points. `@PostConstruct` and `@PreDestroy` operate on an individual bean's lifecycle, not on the factory's definitions or on other beans' post-processing. An application event listener is not a substitute for either lifecycle extension point.

Question 5

New Single answer

Topic: Data Management

Skill tested: Use JdbcTemplate callbacks and translate database access failures through Spring JDBC.

A reporting endpoint runs a parameterized SQL query that returns many rows and maps each row into a report record. The code must avoid manual connection and result-set cleanup, preserve Spring's database-independent data-access exception model, and not load the entire result set into a separate intermediate collection. Which implementation is most appropriate?

Correct Answer: B. Use `JdbcTemplate.query` with SQL parameters and a `RowMapper` to map each row.
Explanation:

`JdbcTemplate` manages JDBC resource acquisition and cleanup, binds parameters, and translates JDBC exceptions into Spring's `DataAccessException` hierarchy. A `RowMapper` maps rows as the template processes the result set, avoiding a separately materialized list of generic maps. Direct JDBC in A puts cleanup and exception translation responsibilities back on application code. Returning a live result set from C escapes the template's resource-management boundary. D materializes an intermediate representation that the requirement explicitly avoids.

Question 6

New Multiple answers

Topic: Data Management

Skill tested: Choose transaction propagation and rollback rules for nested Spring service operations.

A payment service invokes a ledger service through a Spring proxy. The ledger operation must join the payment transaction so both database changes commit or roll back together. A validation failure represented by a checked exception must also roll back the transaction. The team uses annotation-driven transaction management and does not want a separate transaction for the ledger call. Which two choices meet these requirements? Select TWO.

Correct Answer: C. Configure `rollbackFor` to include the checked validation exception.; E. Use `Propagation.REQUIRED` for the ledger operation.
Explanation:

`REQUIRED` joins an existing transaction when one is active, so the payment and ledger changes participate in the same transaction. By default, Spring's declarative transaction rules roll back for unchecked exceptions and errors, not every checked exception; specifying the checked validation exception with `rollbackFor` supplies the required rollback behavior. `REQUIRES_NEW` suspends the caller's transaction and starts an independent one, breaking the all-or-nothing requirement. E suppresses the failure without marking rollback, so the transaction may commit.

Question 7

New Single answer

Topic: Data Management

Skill tested: Define Spring Data JPA repository queries through method naming and entity identifiers.

A Spring Boot service uses a JPA entity `Shipment` with a `status` property and a `createdAt` property. The repository must return shipments for a given status, ordered from newest to oldest, while allowing Spring Data to implement the query from the method signature. The team does not want to write JPQL or SQL. Which repository method declaration best fits?

Correct Answer: C. `List findByStatusOrderByCreatedAtDesc(String status);`
Explanation:

Spring Data JPA derives a query from supported repository method-name conventions. `findByStatusOrderByCreatedAtDesc` filters on the entity's `status` property and requests descending order by `createdAt`, without requiring a handwritten query. B does not express the required ordering and its predicates do not match the intended single status filter. C combines a native-style `select *` form with JPQL annotation usage and contradicts the no-query requirement. D is not a derived method signature for filtering by status and ordering by a property.

Question 8

New Single answer

Topic: Spring MVC

Skill tested: Use REST controller mappings and response semantics for resource creation.

A REST API accepts a JSON representation of a new work item at `/work-items`. The server assigns the identifier and persists the item. The client expects the created resource's URI to be discoverable from the response, and the API should use conventional HTTP semantics. Which controller behavior is the best fit?

Correct Answer: B. Handle `POST /work-items`, persist the item, and return `201 Created` with a `Location` header containing the new resource URI.
Explanation:

A `POST` to a collection is the conventional operation for creating a server-identified resource. Returning `201 Created` and a `Location` header identifies the newly created resource and satisfies the client's discovery requirement. GET is intended to retrieve representations, not create resources. The described operation is not an update to a client-selected resource, so PUT in C does not fit. Redirecting to the collection with 302 in D neither identifies the new resource nor uses the clearest creation response semantics.

Question 9

New Single answer

Topic: Spring MVC

Skill tested: Configure RestTemplate calls with request parameters and response handling.

A service calls an external inventory REST endpoint using `RestTemplate`. The endpoint accepts a product code as a path variable and returns a JSON representation of `StockLevel`. The client must let Spring's configured message converters deserialize the response and must avoid concatenating untrusted product codes directly into a URL. Which approach is most appropriate?

Correct Answer: B. Build a URI template with a `{code}` placeholder and pass the product code as a URI variable to `getForObject` or `getForEntity`.
Explanation:

A URI template with a separate path-variable argument allows `RestTemplate` to expand and encode the variable appropriately, while specifying `StockLevel.class` as the response type lets configured message converters deserialize JSON. B requests a string and an unsafe cast cannot turn that string into the domain object; direct concatenation also risks malformed or improperly encoded paths. POST is not appropriate merely to trigger conversion, because the remote resource is being retrieved. D confuses the URI variable with the required response type.

Question 10

New Single answer

Topic: Testing

Skill tested: Use Spring Boot test slices and MockMvc to test MVC behavior without a full server.

A team needs a fast test of a controller's request mapping, JSON serialization, validation response, and HTTP status codes. The test must use the Spring MVC infrastructure but should not initialize JPA repositories or start an embedded server. Which setup is the best fit?

Correct Answer: A. Use `@WebMvcTest` for the controller and `MockMvc` to issue requests, providing mocks for required collaborators.
Explanation:

`@WebMvcTest` loads a focused MVC slice, including relevant web configuration and message conversion, while excluding unrelated persistence components. `MockMvc` exercises request mapping, binding, validation, serialization, and response status behavior without starting a server. A starts an embedded server and loads a broader application context than the constraints allow. `@DataJpaTest` focuses on persistence rather than MVC. Direct instantiation bypasses Spring MVC request processing and therefore cannot verify the required HTTP behavior.

Question 11

New Multiple answers

Topic: Testing

Skill tested: Configure Spring integration tests with profiles and transactional database rollback.

An integration test must load the Spring application context, use a test-specific database configuration selected by a profile, and leave no committed database changes after each test. The test uses Spring's test support and JUnit 5. Which two practices are appropriate? Select TWO.

Correct Answer: A. Use `@ActiveProfiles` to select the test profile for the test context.; D. Annotate the test with Spring's `@Transactional` so test-managed transaction changes are rolled back by default after the test.
Explanation:

`@ActiveProfiles` activates the test profile when Spring builds the test context, allowing profile-specific configuration to be selected. Spring's test-managed transaction support rolls back a transactional test by default, preventing committed data from persisting between tests. `@WebMvcTest` is an MVC slice, not a full repository integration-test context. `@Commit` requests commit rather than rollback. Manually avoiding the Spring test context would defeat the stated integration-testing requirement and add unnecessary transaction-management code.

Question 12

New Single answer

Topic: Security

Skill tested: Separate authentication from authorization when securing application endpoints.

A Spring Boot API authenticates users with an established authentication mechanism. A new endpoint should be accessible only to authenticated users with the `REPORT_READER` authority, while the health check remains available without authentication for the load balancer. No user should gain access to other protected endpoints merely by being authenticated. Which authorization design is most appropriate?

Correct Answer: D. Require the `REPORT_READER` authority for the report endpoint, permit the health-check path, and require authentication for other requests.
Explanation:

Authentication establishes the caller's identity; authorization determines what that identity may access. A narrowly scoped authority rule for the report endpoint, an explicit exception for the health-check path, and authentication for remaining endpoints preserve the stated access boundaries. A allows authenticated users without the required authority to reach protected endpoints. C violates the load balancer's unauthenticated health-check requirement. Checking only for a non-empty username in D is not a reliable authorization policy and bypasses Spring Security's access-control mechanisms.

Question 13

New Single answer

Topic: Security

Skill tested: Protect service operations with Spring method-level authorization.

A service method that exports customer records is called by both a web controller and a scheduled job. The export must be restricted consistently regardless of the caller, and the authorization decision must be based on a Spring Security authority rather than duplicated in each entry point. Which approach best meets the requirement?

Correct Answer: D. Add an authority-based method security annotation to the service method and enable method security in the application.
Explanation:

Method security protects the service operation at the method boundary, so both controller-driven and scheduled invocations are subject to the same authority rule when invoked through Spring's proxied bean. The application must enable the applicable method-security support. A controller-only check in B does not protect calls from the scheduled job or other callers. `@Transactional` manages transaction behavior, not permissions. Request-mapping conditions apply to web requests and do not govern scheduled method invocations.

Question 14

New Multiple answers

Topic: Spring Boot

Skill tested: Control Spring Boot configuration precedence and select profile-specific external properties.

A Boot service is packaged once and deployed to development and production. Operators must supply the active profile and database URL at deployment time, while the application retains safe defaults for local use. The production settings must not be baked into the artifact, and command-line configuration is available to the deployment system. Which two approaches satisfy these requirements? Select TWO.

Correct Answer: D. Use externalized configuration such as profile-specific configuration files or environment variables, keeping production secrets and values out of the packaged artifact.; E. Supply `spring.profiles.active` and the database URL through deployment-time command-line arguments or environment variables.
Explanation:

Spring Boot supports externalized configuration, including command-line arguments, environment variables, and profile-specific configuration. Supplying profile and database values at deployment time lets the same artifact run in multiple environments while preserving local defaults and avoiding production settings embedded in the build. Separate artifacts in C increase drift and violate the single-artifact requirement. D incorrectly assumes environment variables cannot override packaged configuration. SpEL can be useful for expressions, but E needlessly bypasses Boot's established property-source mechanism.