22 free VMware 2V0-72.22 practice questions from the CertStash pack of 90, each with the correct answer and a full explanation. The rule is the same for every exam: ten free on the product page, 22 free here, all 90 in the pack, and each step includes the one before it.
Get all 90 questions (US$39) · Download the first 10 as a PDF
Question 1
Which statement is true? (Choose the best answer.)
Show answer and explanation
Correct answer: D. @ActiveProfiles is a class-level annotation that is used to declare which bean definition profiles should be active when loaded an ApplicationContext for an integration test.
@ActiveProfiles is a class-level annotation used to declare which bean definition profiles should be active when an ApplicationContext is loaded for an integration test. This allows tests to run with specific Spring profiles enabled, such as test or development profiles, enabling different bean configurations for different test scenarios.
Why the other options are wrong
- A. This describes @RecordApplicationEvents, not @ActiveProfiles.
- B. Bootstrapping configuration is handled by @BootstrapWith, not @ActiveProfiles.
- C. This describes @TestPropertySource, which configures property file locations and inlined properties, not @ActiveProfiles.
Question 2
Which two statements are true about REST? (Choose two.)
Show answer and explanation
Correct answer: C, D. REST is Reliable; REST is Interoperable.
REST is Interoperable because it uses standard HTTP protocols and representations that work across different systems and platforms. REST is Reliable because HTTP provides built-in reliability mechanisms and idempotency guarantees for safe operations. REST is not a protocol itself but an architectural style; it is stateless rather than stateful; and relative is not a characteristic of REST.
Why the other options are wrong
- A. REST is an architectural style, not a protocol; HTTP is the protocol typically used to implement REST.
- B. REST is inherently stateless, not stateful; state information should be transferred in requests and responses.
- E. Relative is not a defining characteristic of REST architecture.
Question 3
Spring Boot will find and load property files in which of the following? (Choose the best answer.)
Show answer and explanation
Correct answer: C. application.properties or application.yml, usually located in the classpath root.
Spring Boot automatically loads configuration from application.properties or application.yml files, typically located in the classpath root or within the application's configuration directories. These are the standard default property file names that Spring Boot recognizes and processes without additional configuration.
Why the other options are wrong
- A. Spring Boot does not automatically load properties files based on the @SpringBootApplication class name.
- B. config.properties or config.yml are not standard default property file names for Spring Boot.
- D. env.properties or env.yml are not standard default property file names for Spring Boot configuration.
Question 4
Which three dependencies are provided by the spring-boot-starter-test? (Choose three.)
Show answer and explanation
Correct answer: B, C, D. Hamcrest; spring-test; Junit
The spring-boot-starter-test dependency provides Hamcrest for matchers, spring-test for Spring testing support, and JUnit for test execution. These three are core testing dependencies included in the starter. Cucumber, EasyMock, and PowerMock are third-party testing libraries that are not included in the standard spring-boot-starter-test package.
Why the other options are wrong
- A. Cucumber is not included in spring-boot-starter-test; it must be added separately.
- E. EasyMock is not included in spring-boot-starter-test; it must be added as a separate dependency.
- F. PowerMock is not included in spring-boot-starter-test; it must be added as a separate dependency.
Question 5
Which two statements are correct regarding Spring Boot auto-configuration customization? (Choose two.)
Show answer and explanation
Correct answer: A, B. Use the @AutoConfigureAfter or @AutoConfigureBefore annotations to apply configuration in a specific order; Disable specific auto-configuration classes by using the exclude attribute on the @EnableAutoConfiguation annotation.
@AutoConfigureAfter and @AutoConfigureBefore annotations control the order in which auto-configuration classes are applied. The exclude attribute on @EnableAutoConfiguration (or equivalently, the exclude property in spring.boot.autoconfigure.exclude) disables specific auto-configuration classes. These are the standard mechanisms for customizing auto-configuration behavior.
Why the other options are wrong
- C. Subclassing auto-configuration classes is not a recommended approach; use configuration properties and conditional beans instead.
- D. Component scanning should not be enabled within auto-configuration classes to avoid discovering unintended components; use explicit bean definitions.
- E. @AutoConfigureOrder is not a standard Spring annotation; ordering is controlled via @AutoConfigureAfter and @AutoConfigureBefore.
Question 6
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.
For Spring to automatically detect and load a class annotated with @Component as a bean, component scanning must be enabled. This is accomplished through the @ComponentScan annotation in a Java configuration class, which tells Spring where to look for annotated components. Without @ComponentScan, Spring will not automatically discover @Component-annotated classes.
Why the other options are wrong
- A. A valid bean name is optional; Spring generates a default name if none is specified.
- C. @Scope defines the lifecycle of a bean but does not enable detection.
- D. @Bean is used to explicitly define beans in configuration classes, not for detecting @Component annotations.
Question 7
Which two options will inject the value of the daily.limit system property? (Choose two.)
Show answer and explanation
Correct answer: C, D. @Value(“$(daily.limit)”); @Value(“#{systemProperties[‘daily.limit’]}”)
A system property can be injected with a property placeholder such as ${daily.limit}, which Spring resolves from the Environment, including JVM system properties. It can also be read with SpEL using the systemProperties map with bracket notation, #{systemProperties['daily.limit']}. Bracket notation is needed because the key itself contains a dot.
Why the other options are wrong
- A. #{daily.limit} is evaluated as a bean named daily with a property limit, not as a system property.
- B. Placeholder syntax does not support the systemProperties SpEL variable, so this expression does not resolve.
- E. Dot notation treats daily and limit as separate navigation steps, so the key daily.limit is never found.
Question 8
Which two options are REST principles? (Choose two.)
Show answer and explanation
Correct answer: A, B. RESTful applications use a stateless architecture; RESTful application use HTTP headers and status codes as a contract with the clients.
REST (Representational State Transfer) is built on stateless architecture, meaning each request contains all necessary information and the server does not store client context between requests. RESTful applications use HTTP headers and status codes as contracts with clients to communicate resource state and operation results. These are fundamental REST constraints that enable scalability and reliability.
Why the other options are wrong
- C. RESTful applications can and do use caching; HTTP caching mechanisms are part of REST design.
- D. REST requires statelessness; servers must not keep track of client state between requests.
- E. REST promotes loose coupling between clients and servers through standard interfaces and representations.
Question 9
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.
In Spring Boot web slice tests, mocking Spring beans is done using the @MockBean annotation, which creates a mock bean in the test context that replaces the actual bean. This allows isolated testing of web components without loading unnecessary dependencies.
Why the other options are wrong
- B. Beans in the web slice test context can be mocked by using @MockBean, which replaces the actual bean.
- C. Mocks are fully supported in Spring Boot web slice tests through @MockBean.
- D. @Mock is a Mockito annotation for unit tests; @MockBean is the Spring Boot specific annotation for slice tests.
Question 10
Which two statements are true regarding Spring Security? (Choose two.)
Show answer and explanation
Correct answer: A, C. Access control can be configured at the method level; Authentication data can be accessed using a variety of different mechanisms, including databases and LDAP.
Spring Security supports method-level access control through annotations like @PreAuthorize and @PostAuthorize, allowing fine-grained authorization decisions. Authentication data can be sourced from various mechanisms including relational databases, LDAP servers, and custom authentication providers, providing flexibility in authentication infrastructure.
Why the other options are wrong
- B. Spring Security does not require a JAAS policy file; it provides its own authentication and authorization framework.
- D. permitAll() bypasses Spring security filters for specific endpoints, not the entire security framework.
- E. Spring Security provides its own implementation rather than strictly following Java EE Security specifications.
Question 11
Which two use cases can be addressed by the method level security annotation @PreAuthorize? (Choose two.)
Show answer and explanation
Correct answer: A, E. Allow access to a method based on user identity; Allow access to a method based on roles.
@PreAuthorize is a method-level security annotation that can evaluate SpEL expressions to determine access. It supports access control based on user identity (through authentication) and roles (via hasRole() or hasAnyRole()). It cannot evaluate HTTP methods, request URLs, or returned object properties at the pre-authorization stage (post-authorization requires @PostAuthorize).
Why the other options are wrong
- B. @PreAuthorize evaluates before method execution; @PostAuthorize is used for returned object-based access.
- C. HTTP method checking is performed at the request level, not via @PreAuthorize method-level annotations.
- D. Request URL-based access control is handled by request-level security configuration, not @PreAuthorize.
Question 12
Spring puts each bean instance in a scope. What is the default scope? (Choose the best answer.)
Show answer and explanation
Correct answer: B. singleton
The default bean scope in Spring is singleton, meaning a single instance of the bean is created and shared across the entire application context. This instance is cached and reused for all subsequent requests. Prototype scope creates a new instance for each request, request scope creates a new instance per HTTP request, and session scope creates a new instance per user session, but none of these are the default behavior.
Why the other options are wrong
- A. Prototype is not the default scope; it creates new instances on each request.
- C. Request scope is not the default; it is specific to web applications.
- D. Session scope is not the default; it is specific to web applications.
Question 13
Which two statements are correct regarding the @EnableAutoConfiguration annotation? (Choose two.)
Show answer and explanation
Correct answer: A, B. It is a meta-annotation on the @SpringBootApplication composed annotation; It enables auto-configuration of the ApplicationContext by attempting to guess necessary beans.
@EnableAutoConfiguration is a meta-annotation composed into @SpringBootApplication, enabling Spring Boot to automatically configure the ApplicationContext by inferring which beans are likely needed based on classpath settings and other factors. The location of the annotated class determines where component scanning begins, so it is not package-independent. Auto-configuration applies early in the bean registration process but after configuration class discovery.
Why the other options are wrong
- C. @EnableAutoConfiguration is not a meta-annotation on @SpringBootConfiguration; it is a separate component of @SpringBootApplication.
- D. The package location of the annotated class matters because it determines the base package for component scanning.
- E. Auto-configuration runs early but does not have a guaranteed ordering relative to all user-defined beans in all scenarios.
Question 14
Which two statements are true regarding @DataJpaTest? (Choose two.)
Show answer and explanation
Correct answer: B, D. If an embedded database is on the classpath, it will be used to configure a DataSource by default; It auto-configures a TestEntityManager bean.
@DataJpaTest auto-configures a TestEntityManager bean for testing JPA components, and if an embedded database (H2, HSQLDB, Derby) is on the classpath, it will be automatically used to configure the DataSource by default. TestEntityManager provides EntityManager functionality plus additional testing conveniences, but it doesn't provide ALL EntityManager methods plus more. @DataJpaTest is specific to JPA, not suitable for NoSQL or JdbcTemplate testing.
Why the other options are wrong
- A. TestEntityManager provides EntityManager methods with additional testing utilities, not a strict superset of all EntityManager methods.
- C. @DataJpaTest is designed for JPA testing only, not NoSQL components.
- E. @DataJpaTest is not appropriate for testing JdbcTemplate; use @JdbcTest instead.
Question 15
Which two statements are correct when @SpringBootApplication is annotated on a class? (Choose two.)
Show answer and explanation
Correct answer: A, B. It causes Spring Boot to enable auto-configuration by default; Component scanning will start from the package of the class.
@SpringBootApplication is a composed annotation that includes @EnableAutoConfiguration, causing Spring Boot to enable automatic configuration of the ApplicationContext by detecting necessary beans. It also includes @ComponentScan, which starts component scanning from the package of the annotated class. Other annotations on the class are processed normally, and @Bean methods are recognized and processed as bean definitions.
Why the other options are wrong
- C. Other annotations on the class are not ignored; they are processed as part of the Spring configuration.
- D. @Bean methods are processed and recognized as bean definitions, not ignored.
- E. A single ApplicationContext is created for the Spring Boot application; multiple @SpringBootApplication classes would be unusual and create a single context.
Question 16
Which statement is true about the @PropertySource annotation? (Choose the best answer.)
Show answer and explanation
Correct answer: D. Used to add a set of name/value pairs to the Spring Environment from an external source.
@PropertySource is used to add a set of name/value pairs to the Spring Environment from an external property file source. It enables developers to load properties from custom external files beyond the default application.properties, making those properties available through the Environment or @Value injection.
Why the other options are wrong
- A. @PropertySource is not specific to designating application.properties location; it works with any external property file.
- B. @PropertySource loads a set of properties, not just a single property value; @Value is used for individual property lookup.
- C. @PropertySource designates a file, not a directory, and does not manage directory structure.
Question 17
Which two statements are true regarding the RestTemplate class? (Choose two.)
Show answer and explanation
Correct answer: B, C. It automatically supports sending and receiving Java objects; It provides convenience methods for writing REST clients.
RestTemplate provides convenience methods for writing REST clients (C), simplifying HTTP requests and responses. It automatically supports sending and receiving Java objects (B) through HTTP message converters that serialize/deserialize between Java objects and HTTP message bodies (such as JSON). Option A is incorrect because RestTemplate is synchronous and blocking; it does not support asynchronous non-blocking operations (AsyncRestTemplate was its async counterpart, now superseded by WebClient). Option D is incorrect because RestTemplate is for client-side REST consumption, not server-side REST service implementation. Option E is incorrect because RestTemplate fully supports custom headers through request headers customization methods.
Why the other options are wrong
- A. RestTemplate is synchronous and blocking, not asynchronous or non-blocking.
- D. RestTemplate is for writing REST clients, not REST services.
- E. RestTemplate fully supports sending custom headers in HTTP requests.
Question 18
In which three ways are Security filters used in Spring Security? (Choose three.)
Show answer and explanation
Correct answer: B, D, E. To drive authentication; To provide a logout capability; To enforce authorization (access control).
Security filters in Spring Security serve three primary functions: driving authentication (B) by processing authentication requests and credentials, enforcing authorization or access control (E) by checking permissions before allowing resource access, and providing logout capability (D) by invalidating sessions and security contexts. Option A is incorrect because risk governance is not a direct function of security filters. Option C is incorrect because managing application users is typically handled by UserDetailsService and user repositories, not by security filters themselves. Option F is incorrect because data encryption is not a core function of security filters; encryption is usually handled separately in the application.
Why the other options are wrong
- A. Risk governance is not a direct function of Spring Security filters.
- C. User management is handled by UserDetailsService and repositories, not by security filters.
- F. Data encryption is not a primary function of Spring Security filters.
Question 19
Which two statements about the @Autowired annotation are true? (Choose two.)
Show answer and explanation
Correct answer: B, C. Multiple arguments can be injected into a single method using @Autowired; By default, if a dependency cannot be satisfied with @Autowired, Spring throws a RuntimeException.
@Autowired can be applied to methods with multiple parameters, allowing multiple dependencies to be injected into a single method. By default, @Autowired requires a matching bean and throws a NoSuchBeanDefinitionException (a RuntimeException subclass) if no bean is found. Field injection occurs after constructor injection and config methods, but @Autowired on individual fields does inject those specific fields at the appropriate time in the bean lifecycle.
Why the other options are wrong
- A. Fields are injected before config methods (marked with @PostConstruct) are invoked, not after.
- D. @Autowired on a class itself is not a valid usage; it must be applied to fields, methods, or constructors.
- E. BeanPostProcessor and BeanFactoryPostProcessor cannot have dependencies injected via @Autowired because they are special beans created before the dependency injection phase.
Question 20
Which two statements are true concerning the BeanPostProcessor Extension point? (Choose two.)
Show answer and explanation
Correct answer: B, D. Custom BeanPostProcessrs can be implemented for Spring applications; BeanPostProcessors are called during the initialization phase of a bean life cycle.
Custom BeanPostProcessor implementations can be created to customize bean instances during the initialization phase of the bean lifecycle. BeanPostProcessors are called after dependencies have been injected and during the initialization phase (after the bean is constructed and dependency-injected but before it becomes available). BeanFactoryPostProcessor runs earlier in the lifecycle, before BeanPostProcessor. BeanPostProcessors can be ordered using the Ordered interface.
Why the other options are wrong
- A. BeanPostProcessors are called after dependencies have been injected, not before.
- C. BeanFactoryPostProcessors are called before BeanPostProcessors in the Spring lifecycle.
- E. BeanPostProcessors can be ordered in Spring applications by implementing the Ordered interface.
Question 21
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. @Autowired @Qualifier (“foo3”) Foo foo;; @Autowired public void setFoo (@Qualifier (“foo1”) Foo foo) {…}; @Autowired private Foo foo2;
When multiple beans of the same type exist, @Autowired requires disambiguation. Option B uses @Qualifier to explicitly select foo3, which resolves ambiguity. Option C uses @Qualifier on a method parameter to select foo1, which is valid and unambiguous. Option E uses the field name foo2 as an implicit qualifier, Spring matches the field name to the bean id foo2, resolving ambiguity. Option A fails because no qualifier is provided and the field name doesn't match any bean id. Option D fails for the same reason, no qualifier and field name doesn't match. Option F fails because the method parameter name foo2 is not treated as a qualifier; method parameter names are not used for autowiring resolution.
Why the other options are wrong
- A. Autowiring fails due to ambiguity; no qualifier specified and field name doesn't match any bean id.
- D. Autowiring fails due to ambiguity; no qualifier specified and field name doesn't match any bean id.
- F. Method parameter names are not used for autowiring resolution; ambiguity is not resolved.
Question 22
Which two are required to use transactions in Spring? (Choose two.)
Show answer and explanation
Correct answer: A, B. Add @EnableTransactionManagement to a Java configuration class; Annotate a class, an interface, or individual methods requiring a transaction with the @Transactional annotation.
Two elements are required to enable transactions in Spring. First, @EnableTransactionManagement (A) must be added to a Java configuration class to enable transaction support in the Spring container. Second, @Transactional (B) must be applied to classes, interfaces, or methods that require transactional behavior. Together, these enable Spring's AOP-based transaction management. Option C is incorrect because @Transaction does not exist (only @Transactional), and @Service is not required for transactions. Option D is incorrect because implementing TransactionInterceptor is not necessary; Spring handles this internally. Option E is incorrect because Spring automatically provides the AOP advice when @EnableTransactionManagement and @Transactional are used.
Why the other options are wrong
- C. @Transaction does not exist; only @Transactional is valid, and @Service is not required.
- D. Implementing TransactionInterceptor is not necessary; Spring manages this automatically.
- E. Writing custom AOP advice is not required; Spring provides this automatically with proper configuration.
That was 22 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.
Not ready yet? Get the first 42 free as one PDF by email. Get the Half Pack →
