All articles
Practice QuestionsExam Guide

Spring Professional Exam Practice Questions 2025 (With Answers)

March 3, 20268 min read

The best way to prepare for the VMware Spring Professional exam (2V0-72.22) is to practice with questions that match the actual format: scenario-based, with multiple plausible answers and detailed explanations.

Below are 10 representative practice questions covering the key exam topic areas. Each includes the correct answer and an explanation of why each option is right or wrong.


Question 1 — Spring Core: Bean Scopes

Which of the following statements about Spring Bean scopes is correct?

  • A. The prototype scope creates a single shared instance per ApplicationContext
  • B. The singleton scope creates a new instance each time the bean is requested
  • C. The singleton scope creates one instance per ApplicationContext — this is the default
  • D. The request scope is available in any ApplicationContext
  • E. The prototype scope triggers the @PreDestroy callback when the bean is garbage collected
  • F. The session scope can be used outside of a web context

Correct answer: C

Explanation: The singleton scope (the default) means that exactly one instance of the bean is created and shared across the entire ApplicationContext. prototype creates a new instance on each request — it is the opposite of singleton. request and session scopes require a web-aware ApplicationContext. Spring does not manage the destruction of prototype beans, so @PreDestroy is not called on them.


Question 2 — Spring Boot: Auto-Configuration

Which annotation enables auto-configuration in a Spring Boot application?

  • A. @EnableAutoConfiguration only
  • B. @SpringBootApplication only
  • C. Both @SpringBootApplication and @EnableAutoConfiguration enable auto-configuration
  • D. @ComponentScan
  • E. @Configuration
  • F. @AutoConfigureOrder

Correct answer: C

Explanation: @SpringBootApplication is a convenience annotation that combines @Configuration, @ComponentScan, and @EnableAutoConfiguration. Using @SpringBootApplication on a class enables auto-configuration. @EnableAutoConfiguration can also be used directly. @ComponentScan only triggers classpath scanning for components — it does not enable auto-configuration. @Configuration marks a class as a configuration source but does not trigger auto-configuration.


Question 3 — Spring Core: Dependency Injection

Consider the following code:

@Component
public class OrderService {

    private final PaymentService paymentService;

    public OrderService(PaymentService paymentService) {
        this.paymentService = paymentService;
    }
}

What type of dependency injection is demonstrated here?

  • A. Setter injection
  • B. Field injection
  • C. Constructor injection
  • D. Method injection
  • E. Interface injection
  • F. Lookup method injection

Correct answer: C

Explanation: The dependency (PaymentService) is provided through the constructor — this is constructor injection. Spring 4.3+ automatically injects constructor dependencies when there is a single constructor, so @Autowired is not required. Constructor injection is the recommended approach as it produces immutable objects and makes dependencies explicit. Field injection (@Autowired on a field) and setter injection (via annotated setter methods) are the other common approaches.


Question 4 — AOP: Pointcut Expressions

Which pointcut expression matches all methods in the com.example.service package?

  • A. execution(* com.example.service.(..))
  • B. execution(* com.example.service.*.*(..))
  • C. within(com.example.service.*)
  • D. execution(* com.example.service..*.(..))
  • E. @within(com.example.service)
  • F. execution(void com.example.service.*(..))

Correct answers: B and C

Explanation: execution(* com.example.service.*.*(..)) matches any method (*.*) with any return type (*) and any arguments ((..)) in any class directly in the com.example.service package. within(com.example.service.*) is equivalent — it matches all join points within any type in that package. Option A is missing the class-level *. Option D uses .. which would match sub-packages too. Option F only matches void methods. @within matches types annotated with the given annotation, not package members.


Question 5 — Spring Boot: Externalized Configuration

Given the following in application.properties:

app.timeout=30

Which approach correctly injects this value into a Spring Bean?

  • A. @Value("app.timeout") private int timeout;
  • B. @Value("${app.timeout}") private int timeout;
  • C. @Value("#{app.timeout}") private int timeout;
  • D. @Inject("${app.timeout}") private int timeout;
  • E. @ConfigurationProperties(prefix = "app") private int timeout;
  • F. @Property("app.timeout") private int timeout;

Correct answer: B

Explanation: @Value("${app.timeout}") uses the property placeholder syntax to inject a value from the environment (application.properties, environment variables, etc.). Option A is missing the ${} wrapper. Option C uses Spring Expression Language (SpEL) syntax (#{}), which would evaluate as an expression, not a property lookup. @ConfigurationProperties is used on a class to bind a group of properties by prefix — not on an individual field. @Inject and @Property do not support this pattern.


Question 6 — Spring Data: Transactions

What is the default propagation behavior of @Transactional?

  • A. REQUIRES_NEW
  • B. SUPPORTS
  • C. REQUIRED
  • D. MANDATORY
  • E. NESTED
  • F. NOT_SUPPORTED

Correct answer: C

Explanation: The default propagation is REQUIRED, which means: if a transaction already exists, the method participates in it; if not, a new transaction is started. REQUIRES_NEW always starts a new transaction and suspends any existing one. SUPPORTS runs within a transaction if one exists, but does not start one. MANDATORY requires an existing transaction and throws an exception if none exists. NESTED creates a savepoint within an existing transaction. NOT_SUPPORTED suspends any existing transaction and runs without one.


Question 7 — Testing: @SpringBootTest

Which of the following statements about @SpringBootTest is correct?

  • A. @SpringBootTest always starts a real HTTP server on port 8080
  • B. @SpringBootTest loads only the web layer (controllers and filters)
  • C. @SpringBootTest loads the complete application context by default
  • D. @SpringBootTest(webEnvironment = WebEnvironment.MOCK) starts a real embedded server
  • E. @WebMvcTest and @SpringBootTest load the same set of beans
  • F. @SpringBootTest cannot be combined with @MockBean

Correct answer: C

Explanation: @SpringBootTest loads the full ApplicationContext, equivalent to starting the full application. By default it uses WebEnvironment.MOCK, which creates a mock web environment without starting a real server. WebEnvironment.RANDOM_PORT or DEFINED_PORT starts a real embedded server. @WebMvcTest is a slice test that loads only the web layer (controllers, filters, @ControllerAdvice) — not the full context. @MockBean can be freely combined with @SpringBootTest.


Question 8 — Spring Security: Filter Chain

In Spring Security, what is the correct order of these components in the request processing chain?

  • A. DispatcherServlet → SecurityFilterChain → Controller
  • B. SecurityFilterChain → DispatcherServlet → Controller
  • C. Controller → SecurityFilterChain → DispatcherServlet
  • D. DispatcherServlet → Controller → SecurityFilterChain
  • E. SecurityFilterChain → Controller → DispatcherServlet
  • F. Controller → DispatcherServlet → SecurityFilterChain

Correct answer: B

Explanation: Spring Security's SecurityFilterChain is a servlet filter that sits before the DispatcherServlet in the servlet container's filter chain. This means requests are authenticated and authorized before they reach Spring MVC's DispatcherServlet and are dispatched to a Controller. This ordering is fundamental — security is enforced at the filter layer, not inside the application logic.


Question 9 — Spring Boot: Actuator

Which Spring Boot Actuator endpoint shows the current health status of the application and its dependencies?

  • A. /actuator/info
  • B. /actuator/metrics
  • C. /actuator/health
  • D. /actuator/env
  • E. /actuator/status
  • F. /actuator/beans

Correct answer: C

Explanation: /actuator/health aggregates health indicators (database connectivity, disk space, message broker availability, etc.) and returns an UP or DOWN status. /actuator/info shows application build and version metadata. /actuator/metrics exposes JVM and application metrics (memory, threads, HTTP request counts). /actuator/env shows the full environment including all configuration properties. There is no /actuator/status endpoint by default. /actuator/beans lists all beans in the ApplicationContext.


Question 10 — Spring Core: Bean Lifecycle

In the correct Spring Bean lifecycle order, which callback comes first after the bean's properties have been set?

  • A. @PostConstruct method
  • B. afterPropertiesSet() from InitializingBean
  • C. The init-method declared in @Bean(initMethod = "...")
  • D. The BeanPostProcessor.postProcessBeforeInitialization() callback
  • E. The BeanPostProcessor.postProcessAfterInitialization() callback
  • F. The @PreDestroy method

Correct answer: D

Explanation: The correct initialization order after properties are set is:

  1. BeanPostProcessor.postProcessBeforeInitialization() — runs before any init callbacks
  2. @PostConstruct method
  3. InitializingBean.afterPropertiesSet()
  4. The custom init-method
  5. BeanPostProcessor.postProcessAfterInitialization() — runs after all init callbacks

@PreDestroy is a destruction callback, unrelated to initialization. Understanding this order is frequently tested on the 2V0-72.22 exam — BPP callbacks wrap around the bean-level init methods.


Exam Coverage at a Glance

The 2V0-72.22 exam has 60 questions across these topic areas:

TopicApproximate Weight
Spring Core (IoC, DI, Bean lifecycle, AOP)~28%
Spring Boot (Auto-configuration, Actuator, Properties)~28%
Data Management (JDBC, Transactions, JPA)~14%
Testing~14%
Spring MVC and REST~10%
Spring Security~6%

The exam is based on Spring Framework 5.3 and Spring Boot 2.x. Passing score: 300/500 (~76%, approximately 46 out of 60 correct).


Practice More

The 10 questions above represent the style and depth of the actual exam — multiple plausible options, scenario-based reasoning, and detailed explanations that teach the underlying concept, not just the answer.

Try the Free Practice Quiz — interactive quiz with immediate feedback

Read the Complete Exam Guide — all topic areas, study plan, registration walkthrough

View 970+ Questions on Udemy — full practice exam bank with video explanations

Practice This Topic

Reinforce what you've learned with free practice questions and detailed explanations.