Skip to content

2V0-72-22 VMware Practice Questions

Prepare for 2V0-72-22 with more than an answer.

192 questions in the full set20 sample questionsUpdated Aug 11, 2025
Exam fee
$250 USD
Level
Professional
Valid for
No expiration
Domains covered on the exam 6
  1. Spring Core25%
  2. Data Management20%
  3. Spring MVC20%
  4. Testing15%
  5. Security10%
  6. Spring Boot30%
  1. 1

    A developer is writing an integration test for a service layer that interacts with a database. To ensure the test is isolated, they want to use an in-memory H2 database only for the test run. The main application uses PostgreSQL. What is the most idiomatic Spring Boot approach to achieve this?

    Show answer details

    Correct answer: B

    This is the standard and simplest way in Spring Boot. If an embedded database driver (like H2) is found on the classpath with test scope, Spring Boot's DataSourceAutoConfiguration will favor it over other configured datasources during the test phase, automatically setting up an in-memory database without needing explicit configuration files.

  2. 2

    A developer needs to inject a list of all beans that implement the PaymentGateway interface into a service. Which of the following injection points correctly accomplishes this?

    Show answer details

    Correct answer: D

    Spring's dependency injection container has built-in support for collecting all beans of a certain type. By autowiring a List , Spring will find all beans that implement InterfaceType in the application context and inject them as a list into the field.

  3. 3

    A Spring Boot application is being deployed to a new environment where the HTTP port must be configured via an environment variable named APP_PORT. Which entry in application.properties allows the application to use this environment variable, while defaulting to port 8080 if it's not set?

    Show answer details

    Correct answer: A

    This syntax correctly uses a property placeholder. Spring Boot will first look for an environment variable or system property named APP_PORT. If it is not found, it will fall back to the default value of 8080 provided after the colon.

  4. 4

    Scenario
    A logistics company is developing a ShipmentTrackingService. This service consumes messages from an external system via an API, processes them, and updates the shipment status in a database. The processing logic is complex and can occasionally fail due to transient network issues or invalid data. The architects have decided to use Spring's AOP to implement a retry mechanism for the core processing method.

    Code

    @Service
    public class ShipmentProcessor {
    @Transactional
    @Retryable(value = DataAccessException.class, maxAttempts = 3, backoff = @Backoff(delay = 1000))
    public void processShipment(ShipmentData data) {
    // ... database update logic ...
    if (isInvalid(data)) {
    throw new InvalidShipmentDataException("Invalid data");
    }
    }
    }
    

    Requirements

    1. The method should retry up to 3 times if a DataAccessException occurs.
    2. If an InvalidShipmentDataException (which is a RuntimeException but not a DataAccessException) is thrown, the method should NOT retry, and the transaction should be rolled back immediately.
    3. The retry and transactional behaviors must work together correctly.

    Question
    Given the code and requirements, what is the expected behavior when processShipment is called with data that causes an InvalidShipmentDataException?

    Show answer details

    Correct answer: B

    This is the correct behavior. The @Retryable annotation is configured to only retry on DataAccessException. Since InvalidShipmentDataException is not a DataAccessException (or a subclass of it), the retry advice will not trigger. Because it is an unchecked RuntimeException, the default behavior of @Transactional will be to mark the transaction for rollback. Therefore, the method fails immediately, and the transaction is rolled back.

  5. 5

    A service method in ServiceA calls a public method in ServiceB. Both methods are annotated with @Transactional(propagation = Propagation.REQUIRES_NEW). What is the transactional behavior when the method in ServiceA is invoked?

    sequenceDiagram participant Client participant ServiceA participant ServiceB participant DB as Database Client->>ServiceA: invokeMethodA() Note over ServiceA,DB: Start Transaction A ServiceA->>ServiceB: invokeMethodB() Note over ServiceA: Suspend Transaction A Note over ServiceB,DB: Start Transaction B ServiceB-->>ServiceA: return Note over ServiceB,DB: Commit/Rollback Transaction B Note over ServiceA: Resume Transaction A ServiceA-->>Client: return Note over ServiceA,DB: Commit/Rollback Transaction A

    Show answer details

    Correct answer: C

    Propagation.REQUIRES_NEW always starts a new, independent transaction. If an existing transaction is active, it will be suspended. The inner transaction in ServiceB can commit or roll back without affecting the outcome of the outer transaction in ServiceA.

  6. 6

    A development team is building a library of custom Spring Boot auto-configurations. To ensure a custom configuration MyCustomAutoConfiguration is only activated when the ThirdPartyService.class is present on the classpath, and a bean of type DataSource has already been configured by another auto-configuration, which combination of annotations should be used on the configuration class?

    Show answer details

    Correct answer: B

    The correct approach is to use @ConditionalOnClass(ThirdPartyService.class) to check for the presence of the class on the classpath, and @ConditionalOnBean(DataSource.class) to ensure a DataSource bean is already present in the context before this configuration is applied. @Configuration is necessary to mark the class as a source of bean definitions.

  7. 7

    A developer is implementing an AOP aspect to log method executions. They notice that when a public method calls another public method within the same service bean, the advice is not triggered for the second, inner method call. What is the fundamental reason for this behavior in Spring's proxy-based AOP?

    Show answer details

    Correct answer: B

    Spring AOP works by creating a proxy object that wraps the actual bean. External calls go through the proxy, allowing advices to be applied. However, an internal method call (this.innerMethod()) is a direct invocation on the target object itself, completely bypassing the proxy and any associated AOP logic. This is known as the self-invocation problem.

  8. 8

    A financial application needs to perform a complex operation involving two separate database updates. The outer service method, transferFunds(), is annotated with @Transactional(propagation = Propagation.REQUIRED). It calls an inner service method, logAudit(), which must commit its record regardless of whether the transferFunds operation succeeds or fails. Which propagation level should be applied to the logAudit() method to achieve this behavior?

    Show answer details

    Correct answer: D

    REQUIRES_NEW starts a new, independent transaction for the logAudit() method. The existing transaction (from transferFunds()) is suspended. This allows the inner transaction to commit on its own, ensuring the audit log is saved even if the outer transaction fails and rolls back.

  9. 9

    A developer needs to configure a Spring Security setup for a REST API. The requirement is to allow unauthenticated access to /api/public/** endpoints, while all other endpoints under /api/** must be authenticated. Which two of the following HttpSecurity configurations correctly implement this requirement? (Select TWO)

    Show answer details

    Correct answer: B, D

    This configuration correctly uses the principle of ordering matchers from most specific to most general. It first permits all access to /api/public/** and then requires authentication for all other /api/** paths.

    This is also a correct and common pattern. It permits access to the public endpoints and then uses anyRequest().authenticated() as a catch-all to secure everything else. Since /api/public/** is matched first, it works as required.

  10. 10

    When writing a slice test for a Spring Data JPA repository using @DataJpaTest, the test transaction will, by default, roll back at the end of each test method.

    Show answer details

    Correct answer: A

    The @DataJpaTest annotation is meta-annotated with @Transactional. In a test context, @Transactional ensures that each test method runs in a transaction that is rolled back by default upon completion. This keeps tests isolated and prevents them from polluting the database state for subsequent tests.

Create an account to continue.