10 free VMware 2V0-72.22 practice questions with the correct answer and a full explanation for each, taken from the CertStash pack of 90 questions. Work through them, then open each answer to check your reasoning.
Get all 90 questions (US$39) · Download these 10 as a PDF
Question 1
If a class is annotated with @Component, what should be done to have Spring automatically detect the annotated class and load it as a bean?
(Choose the best answer.)
Show answer and explanation
Correct answer: B. Ensure a valid @ComponentScan annotation in the Java configuration is specified.
Java configuration is specified. @Component annotation marks a class as a Spring bean candidate, but Spring must be configured to scan for these annotated classes. The @ComponentScan annotation enables classpath scanning and automatic detection of @Component-annotated classes. Without @ComponentScan, Spring will not discover and load the annotated class as a bean, regardless of the annotation's presence.
Why the other options are wrong
- A. A valid bean name is optional in @Component; if not specified, the class name (lowercase first letter) is used as the bean name.
- C. @Scope defines the lifecycle of an already-detected bean but does not enable detection itself.
- D. @Bean is used in configuration classes to manually define beans; it is not used with @Component for automatic detection.
Question 2
Which two options will inject the value of the daily.limit system property? (Choose two.)
Show answer and explanation
Correct answer: C, D
C. @Value(“$(daily.limit)”) D. @Value(“#{systemProperties[‘daily.limit’]}”) There are two supported ways to read a JVM system property into a bean: a property placeholder or a SpEL expression. ${daily.limit} is resolved by the PropertySourcesPlaceholderConfigurer against the Environment, and the Environment includes the system properties source. #{systemProperties['daily.limit']} evaluates SpEL against the systemProperties map, using bracket notation because the key itself contains a dot.
Why the other options are wrong
- A. #{daily.limit} is a SpEL expression that navigates the property daily on the root object and then limit on its result, so it never reads the system properties.
- B. ${systemProperties.daily.limit} asks the Environment for a property literally named systemProperties.daily.limit, and no such property exists.
- E. SpEL treats every dot as a navigation step, so systemProperties.daily.limit looks for a map key named daily instead of the key daily.limit.
Question 3
Which two options are REST principles? (Choose two.)
Show answer and explanation
Correct answer: A, B
A. RESTful applications use a stateless architecture. B. RESTful application use HTTP headers and status codes as a contract with the clients. Statelessness is a core REST principle; each request contains all information needed for the server to process it without relying on stored client context. HTTP headers and status codes form the contract between RESTful services and clients, allowing clients to understand responses and server state changes. Caching is actually encouraged in REST to improve performance, client state tracking violates the stateless principle, and REST favors loose coupling through standardized HTTP interactions.
Why the other options are wrong
- C. Caching is a recommended practice in REST architecture to improve performance and reduce server load.
- D. Keeping track of client state violates the stateless principle, which is fundamental to REST design.
- E. REST specifically favors loose coupling between clients and servers through wel-efined HTTP contracts and standardized resource representations.
Question 4
Which option is true about use of mocks in a Spring Boot web slice test? (Choose the best answer.)
Show answer and explanation
Correct answer: A. Mocking a Spring Bean requires annotating it with @MockBean annotation.
@MockBean annotation. @MockBean is the correct annotation for mocking Spring Beans in Spring Boot web slice tests. When annotated with @MockBean, a bean is replaced in the application context with a mock instance, allowing verification of interactions. This annotation integrates Spring's testing infrastructure with Mockito to manage bean lifecycle and injection within the test context.
Why the other options are wrong
- B. Spring Beans can be mocked even if they already exist in the context; @MockBean replaces the existing bean with a mock.
- C. Mocks are fully supported and commonly used in Spring Boot web slice tests.
- D. @Mock is a Mockito annotation for simple mock creation outside of Spring context; @MockBean is required for Spring-integrated mocking.
Question 5
Which two statements are true regarding Spring Security? (Choose two.)
Show answer and explanation
Correct answer: A, C
A. Access control can be configured at the method level. C. Authentication data can be accessed using a variety of different mechanisms, including databases and LDAP. Spring Security supports access control at the method level through annotations such as @PreAuthorize, @PostAuthorize, @Secured and the JSR-250 annotations, enabled with @EnableMethodSecurity. It also reads authentication data from many sources, including JDBC databases, LDAP directories, in memory stores, OAuth2 providers and custom AuthenticationProvider implementations. This pluggable design is why Spring Security fits both simple and enterprise scenarios.
Why the other options are wrong
- B. No JAAS policy file is required; Spring Security is configured with Spring beans, a SecurityFilterChain and annotations.
- D. permitAll() still runs the full Spring Security filter chain, it simply authorizes every request that matches the rule.
- E. Spring Security is its own framework with its own model, it is not an implementation of the Java EE Security specification.
Question 6
Which two statements are true regarding a Spring Boot-based Spring MVC application? (Choose two.)
Show answer and explanation
Correct answer: A, C
A. The default embedded servlet container can be replaced with Undertow. C. Spring Boot starts up an embedded servlet container by default. Spring Boot automatically starts an embedded servlet container (Tomcat by default) without requiring external deployment, enabling standalone jar execution. The default embedded container can be replaced with alternatives like Jetty or Undertow through dependency management. The default port is 8080, and Spring MVC does not automatically start an in-memory database; databases must be explicitly configured or Spring Data defaults are applied only when dependencies are present.
Why the other options are wrong
- B. Tomcat is the default embedded servlet container in Spring Boot, not Jetty.
- D. The default port for the embedded servlet container is 8080, not 8088.
- E. Spring MVC does not start an in-memory database by default; database initialization requires explicit configuration or relevant dependencies.
Question 7
Which two statements are true regarding Spring and Spring Boot Testing? (Choose two.)
Show answer and explanation
Correct answer: B, E
B. @SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext. E. Integration and slice testing are both supported. @SpringJUnitConfig and @SpringBootTest both bootstrap an ApplicationContext for tests, the first from explicit configuration classes and the second from the Spring Boot application configuration. Spring Boot also supports full integration tests as well as slice tests such as @WebMvcTest, @DataJpaTest and @JsonTest that load only a focused part of the context. Mockito ships with spring-boot-starter-test, so mocking and spying work without extra setup.
Why the other options are wrong
- A. EasyMock is not bundled with the Spring Boot test starter; Mockito is the supported mocking framework out of the box.
- C. Mockito spies are supported by default, through @Spy and through @MockBean's spy counterpart @SpyBean.
- D. @Mock is a Mockito annotation and @MockBean comes from spring-boot-test, so neither is provided by the spring-test dependency.
Question 8
Refer to the exhibit.
Assume that the application is using Spring transaction management which uses Spring AOP internally.
Choose the statement that describes what is happening when the update1 method is called? (Choose the best answer.)

Show answer and explanation
Correct answer: D. There is only one transaction initiated by update1() because the call to update2() does not go through the proxy.
When update1() is called on a Spring-managed bean, the call goes through the proxy created by Spring AOP, which initiates a transaction with REQUIRED propagation. However, when update1() internally calls update2() via a direct method call (this.update2()), this call does NOT go through the proxy, it bypasses the AOP interceptor entirely. Therefore, update2()'s @Transactional annotation with REQUIRES_NEW is never evaluated, and no new transaction is created. Only the single transaction initiated by the proxy for update1() exists throughout the execution.
Why the other options are wrong
- A. REQUIRES_NEW would create a new transaction only if the call went through the proxy, which it does not in this internal method call scenario.
- B. No exception is thrown; the REQUIRES_NEW annotation is simply ignored because the method call bypasses the proxy and the AOP interceptor.
- C. REQUIRES_NEW does not apply here because the annotated method is never invoked through the proxy, so the propagation behavior is irrelevant.
Question 9
Which two statements are true concerning constructor injection? (Choose two.)
Show answer and explanation
Correct answer: A, C
A. If there is only one constructor the @Autowired annotation is not required. C. Constructor injection is preferred over field injection to support unit testing. When a class has only one constructor, Spring can automatically inject dependencies without requiring the @Autowired annotation, making the code cleaner. Constructor injection is preferred over field injection because dependencies are final and immutable, making objects easier to unit test without Spring's container; dependencies can be provided to constructors in test code without reflection. Constructor injection supports multiple dependencies through multiple parameters and enables testing with different dependency combinations.
Why the other options are wrong
- B. Constructor injection can accept multiple parameters, allowing injection of multiple values in a single constructor.
- D. Multiple constructors without @Autowired annotation create ambiguity; Spring requires @Autowired on one constructor to determine which to use.
- E. Constructor injection is preferred for unit testing because dependencies are explicit and can be injected directly without requiring Spring's container or reflection.
Question 10
Given an ApplicationContext containing three bean definitions of type Foo with bean ids foo1, foo2, and foo3, which three @Autowired scenarios are valid and will allow the ApplicationContext to initialize successfully? (Choose three.)
Show answer and explanation
Correct answer: B, C, E
B. @Autowired @Qualifier (“foo3”) Foo foo; C. @Autowired public void setFoo (@Qualifier (“foo1”) Foo foo) {…} E. @Autowired private Foo foo2; With three candidates of type Foo, injection by type alone is ambiguous and must be disambiguated. Option B uses @Qualifier("foo3") on the field and option C uses @Qualifier("foo1") on the setter parameter, both naming the bean explicitly. Option E works because the field name foo2 matches the bean id foo2, and Spring falls back to the field name when several beans match the type.
Why the other options are wrong
- A. The setter injects by type with no qualifier and no matching name, so the context fails with NoUniqueBeanDefinitionException.
- D. The field name foo matches no bean id, leaving three type matches and an unresolvable dependency.
- F. Method parameter names are not guaranteed to survive compilation, so naming the parameter foo2 is not a dependable way to select one of the three candidates; use @Qualifier on the parameter instead.
That was 10 of 90.
The full VMware 2V0-72.22 pack has all 90 questions, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.
