ExamDumpster

Free 2V0-72-22 sample questions

Each free 2V0-72-22 sample question below has the correct answer and an explanation. You will meet Spring Boot setup, transactions and REST controllers among them. Use them to spot the Spring topics you need to review.

Try them in the simulator Same questions, with study, timed and flashcard modes.

Showing 10 of 20 free sample questions.

Question 1Choose one

A developer is using Spring Expression Language (SpEL) to conditionally create a bean. The goal is to create the `EmailService` bean only if the application profile is 'production' AND a system property named 'email.enabled' is set to 'true'. Which `@ConditionalOnExpression` annotation is correct?

Question 2Choose one

A developer wants to implement method-level security on a service method. The requirement is that only users who have the role 'ADMIN' OR are the owner of the account can invoke the `getAccountDetails` method. The method signature is `getAccountDetails(String username)`. How should the `@PreAuthorize` annotation be written to enforce this rule?

Question 3Choose 2

Which of the following statements accurately describe the differences between `@RestController` and `@Controller` in Spring MVC? (Select TWO)

Question 4Choose one

A developer needs to create a custom health indicator for a Spring Boot application that checks the status of an external REST service. Which interface must the developer implement to create this custom health check?

Question 5Choose one

True or False: A `BeanPostProcessor` allows you to modify the bean definition, such as changing its scope or property values, before the bean is instantiated.

Question 6Choose one

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?

Question 7Choose one

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?

Question 8Choose one

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?

Question 9Choose one

**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** ```java @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`?

Question 10Choose one

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

10 more free samples are waiting

Create a free account to unlock the whole 2V0-72-22 sample bank, or get full access to all 192 practice questions in the simulator.

Create account