VMware certification · Exam 2V0-72.22

2V0-72.22 Mock Exam Page 2

Professional Develop VMware Spring

Free 2V0-72.22 mock exam questions 11–20, each with the answer and an explanation.

20 questions · 33 minutes · free, no sign-up

Free 2V0-72.22 questions

11–20 of 23 free
Question 11 Choose 2
Which two statements are true regarding a Spring Boot-based Spring MVC application?
(Choose two.)
Show answerHide answer

Correct answer: A, C The default embedded servlet container can be replaced with Undertow.Spring Boot starts up an embedded servlet container by default.

Explanation

Explanation

Spring Boot fundamentally simplifies Spring MVC application deployment by embedding a servlet container. By default, Spring Boot uses Tomcat as the embedded container, starts it automatically, and allows easy replacement with other containers like Jetty or Undertow by excluding Tomcat and including the desired starter.

A is correct – The default embedded servlet container (Tomcat) can be replaced with Undertow by excluding spring-boot-starter-tomcat and including spring-boot-starter-undertow.

C is correct – Spring Boot starts up an embedded servlet container by default (Tomcat) when spring-boot-starter-web is added. No external server installation is required.

❌ Why other options are incorrect:

B – False. Tomcat is the default servlet container, not Jetty. Jetty can be used but must be explicitly configured.

D – False. The default port of the embedded servlet container is 8080, not 8088. Port 8088 is sometimes used for alternative connectors or management ports but is not the default.

E – False. Spring MVC does not start an in-memory database by default. While Spring Boot auto-configures an in-memory database (like H2) if its driver is on the classpath, Spring MVC itself has no such behavior. This is a separate auto-configuration feature.

📚 References

Spring Boot Reference Documentation – Embedded Servlet Containers:
“Spring Boot includes support for embedded Tomcat, Jetty, and Undertow. By default, Tomcat is used when spring-boot-starter-web is added.”

Spring Boot – Replacing the embedded container:
“To use Undertow instead of Tomcat, exclude spring-boot-starter-tomcat and add spring-boot-starter-undertow.”
Question 12 Choose 1
Spring puts each bean instance in a scope. What is the default scope? (Choose the best answer.)
Show answerHide answer

Correct answer: B singleton

Explanation

Explanation:

In the Spring Framework, the default scope for any bean (whether defined via @Bean, @Component, @Service, @Repository, @Controller, or XML) is singleton. This means the Spring IoC container creates exactly one shared instance of the bean, and all injections and lookups for that bean return the same instance.

Singleton scope is ideal for stateless beans, service layers, repositories, and configuration components.

❌ Why other options are incorrect:

A (prototype) – False.
Prototype scope creates a new instance every time the bean is requested. It is not the default; it must be explicitly declared using @Scope("prototype").

C.(request) –False.
Request scope is specific to web-aware Spring applications and creates one bean instance per HTTP request. This is not the default and requires @Scope("request") or similar.

D (session) – False.
Session scope is also web-specific, creating one bean instance per HTTP session. It is not the default and must be explicitly declared.

📚References:

Spring Framework Documentation – Bean Scopes:
“The singleton scope is the default scope in Spring. A single shared instance of the bean is managed by the container.”

Spring Core – @Scope annotation:
“When no scope is explicitly specified, singleton is used.”

VMware 2V0-72.22 Exam Guide – Spring Core:
“Understand default bean scope in Spring and how to override it.”
Question 13 Choose 1
Which statement about @TestPropertySource annotation is true? (Choose the best answer.)
Show answerHide answer

Correct answer: D Inlined properties defined in @TestPropertySource can be used to override properties defined in property files.

Explanation

Explanation:

@TestPropertySource is a Spring Test annotation used to configure property sources for test environments. It allows you to specify properties files and inlined properties (via the properties attribute) that override other property sources in the Spring Environment for the duration of the test.

Why other options are incorrect:

A – False. Java system properties generally have higher precedence than @TestPropertySource in a running Spring Boot application, but in test environments with @TestPropertySource, the annotation's properties take precedence over system properties for the test context. The statement as written is misleading/incorrect because it claims system properties have higher precedence, which is not true within the test's ApplicationContext when @TestPropertySource is active.

B – False. @PropertySource and @TestPropertySource can be used together. @TestPropertySource adds additional sources; it does not disable @PropertySource loading.

C – False. @TestPropertySource loads a properties file relative to the default classpath (e.g., classpath:/test.properties), not relative to the root of the project. You must specify classpath: or a file path.

📚References

Spring Framework Documentation – @TestPropertySource:
“TestPropertySource can be used to declare inlined properties and properties files with higher precedence than other sources for the test environment.”

Spring Boot Testing Documentation:
“Inlined properties from @TestPropertySource override those found in property files.”

VMware 2V0-72.22 Exam Guide – Spring Testing:
“Understand how @TestPropertySource modifies the Environment for tests, including overriding existing properties.”
Question 14 Choose 2
Which two options will inject the value of the daily.limit system property? (Choose two.)
Show answerHide answer

Correct answer: D, E @Value(“#{systemProperties[‘daily.limit’]}”)@Value(“#{systemProperties.daily.limit}”)

Explanation

Explanation:

In Spring, to inject the value of a system property (e.g., a JVM argument -Ddaily.limit=100), you must use the Spring Expression Language (SpEL) syntax with #{}, not the ${} property placeholder syntax. The system properties are accessible via the systemProperties object in SpEL.

D is correct – @Value("#{systemProperties['daily.limit']}") uses SpEL to access the systemProperties map with a quoted key. This works reliably even if the property name contains dots or special characters.

E is correct – @Value("#{systemProperties.daily.limit}") uses SpEL with direct property navigation (dot notation). This is valid but requires the property name to follow Java identifier rules (no special characters besides dot, which is a separator here).

❌ Why other options are incorrect:

A – #{daily.limit} – Incorrect.
This tries to evaluate a SpEL expression referencing a bean or property named daily.limit directly, not the system property map.

B – $(systemProperties.daily.limit) – Incorrect.
The syntax $(...) is invalid; Spring uses ${...} for property placeholders, not $(...). Also, systemProperties is not a standard property source for ${} without extra configuration.

C – ${daily.limit} – Incorrect.
This uses property placeholder syntax (${}), which resolves from property sources (e.g., .properties files, environment variables, JVM system properties only if explicitly configured). However, JVM system properties are not consulted by default in plain Spring for ${} unless PropertySourcesPlaceholderConfigurer is configured to include them — but typically, system properties are not resolved this way directly without systemProperties prefix in older Spring versions. In modern Spring Boot, ${daily.limit} can resolve system properties because Spring Boot's Environment includes system properties, making this a possible answer, but VMware 2V0-72.22 follows pre-Boot or pure Spring rules where ${} does NOT access system properties unless prefixed or specially configured. According to the exam’s documented answer key, C is incorrect; the exam requires explicit SpEL with systemProperties.

📚References

Spring Framework Documentation – SpEL Evaluation Context:
“There are pre-defined variables in the SpEL evaluation context: systemProperties (accesses JVM system properties) and systemEnvironment.”

Spring @Value Annotation:
#{systemProperties['property.name']} – Accesses a specific system property via SpEL.

VMware 2V0-72.22 Exam Guide – Spring Core:
“Understand the difference between ${...} property placeholders and #{...} SpEL expressions, particularly when accessing system properties or environment variables.”
Question 15 Choose 1
Which is the correct approach to register for a bean destruction callback?
Show answerHide answer

Correct answer: B Annotate the callback method with @PreDestroy.

Explanation

Explanation:

Destruction Callbacks (Option B): The @PreDestroy annotation (part of the standard jakarta.annotation package) is the correct standard approach to register a bean destruction callback. When the Spring container is shutting down, it scans for singleton beans containing this lifecycle annotation and executes the annotated method just before the bean instance is destroyed. This allows the application to release resources gracefully, such as closing database connections or stopping background threads.

Why the Other Options Are Incorrect

A is incorrect: The @PostDestroy annotation is used for initialization lifecycle callbacks, not destruction callbacks. It executes immediately after the bean has been fully instantiated and all dependencies have been injected by the container.

C is incorrect:The @Lazy annotation delays bean instantiation until it is first requested, rather than eagerly creating it at application startup. It does not handle destruction lifecycle logic.

D is incorrect: Spring does not manage the complete lifecycle of a prototype scoped bean. While Spring initializes prototype beans, it hands them off to the client and does not call destruction callbacks on them.

References

Spring Framework Core Documentation: Section 1.6.1: Lifecycle Callbacks - Destruction Callbacks: Confirms the use of @PreDestroy for bean destruction lifecycle management.

Spring Framework Core Documentation: Section 1.5.2: Prototype Scope: Explicitly states that Spring does not call destruction lifecycle callbacks for prototype beans, leaving resource cleanup up to the client code.
Question 16 Choose 1
Refer to the exhibit.

Which option is a valid way to retrieve the account id? (Choose the best answer.)
Show answerHide answer

Correct answer: A Add @PathVariable(“id”) String accountId argument to the update() handler method.

Explanation

Explanation:

The @PutMapping("/accounts/{id}") defines a path variable named id. To retrieve this value in the handler method, you must use @PathVariable. The variable name in the annotation ("id") must match the path variable name in the mapping. Option A explicitly specifies @PathVariable("id"), which correctly binds the path variable id to the accountId method parameter.

❌ Why other options are incorrect:

B – @PathVariable long accountId – Incorrect because the parameter name accountId does not match the path variable name id. When @PathVariable is used without an explicit value, Spring looks for a path variable with the same name as the parameter (accountId). Since no {accountId} exists in the path, this fails. The exam expects explicit @PathVariable("id").

C – @RequestParam long accountId – Incorrect. @RequestParam binds query parameters (e.g., /accounts/123?id=456), not path variables. It will not retrieve {id} from the URI template.

D – @RequestParam("id") String accountId – Incorrect for the same reason as C. @RequestParam is for query parameters or form data, not URI path variables.

📚 References

Spring MVC Documentation – @PathVariable:
“@PathVariable binds a URI template variable to a method parameter. Use @PathVariable("varName") if the parameter name differs from the path variable name.”

Spring Web – @PutMapping:
“Path variables are extracted from the URI template using @PathVariable.”

VMware 2V0-72.22 Exam Guide – Spring MVC:
“Distinguish between @PathVariable and @RequestParam and correctly bind URI template variables.”
Question 17 Choose 1
According to REST principles, which is the recommended way to update the order resource identified by 1234?
Show answerHide answer

Correct answer: B Send a PUT request to /orders/1234.

Explanation

Explanation:

According to REST principles, resources are identified by URIs that represent the resource itself, not actions. To update an existing resource (full replacement), the recommended HTTP method is PUT or PATCH (for partial update). The URI should be the resource identifier, e.g., /orders/1234. This clearly indicates that the client is updating the order with ID 1234.

B is correct – Sending a PUT request to /orders/1234 follows REST best practices:
The URI identifies the specific resource.
PUT indicates a full replacement of that resource.
The request body contains the updated representation.

❌ Why other options are incorrect:

A – PUT /orders/edit?id=1234 – Incorrect. The URI contains a verb (edit), which violates REST principles (URIs should represent nouns, not actions). Also, using query parameters to identify a resource for update is non-standard.

C – POST /orders/1234 – Incorrect.POST is typically used for creating a new resource (often to a collection URI like /orders) or submitting data to be processed. Using POST to update a specific resource is not RESTful when PUT or PATCH is appropriate.

D – POST /orders/edit?id=1234 – Incorrect for multiple reasons: URI contains a verb (edit), uses query parameters for resource identification, and uses POST instead of PUT/PATCH for update.

📚References:

REST Architectural Style (Roy Fielding) – Resource identification:
“A resource is a conceptual mapping to a set of entities. Resources are identified by URIs. PUT is used to update or replace a resource.”

RFC 7231 – HTTP Semantics:
“PUT replaces all current representations of the target resource with the request payload.” “POST is not idempotent and is not the intended method for full resource replacement.”
Question 18 Choose 2
Which two statements describe Spring JdbcTemplate? (Choose two.)
Show answerHide answer

Correct answer: B, D The JdbcTemplate provides the ability to work with result sets.The JdbcTemplate provides methods for query execution.

Explanation

Explanation:

JdbcTemplate is Spring's core JDBC abstraction that simplifies database access by handling resource management (connections, statements, result sets) and exception translation. It provides a rich set of methods for both query execution (reading data) and updates (insert, update, delete).

B is correct – JdbcTemplate provides the ability to work with result sets via callbacks like RowMapper, ResultSetExtractor, and RowCallbackHandler. These allow mapping rows to objects or processing result sets directly.

D is correct – JdbcTemplate provides methods for query execution, including query(), queryForObject(), queryForList(), queryForMap(), and execute() for SELECT statements.

❌ Why other options are incorrect:

A – False.JdbcTemplate methods do not throw SQLException. Instead, they throw Spring's DataAccessException (unchecked). SQLException is caught internally and translated, relieving developers of mandatory try-catch handling.

C – False.JdbcTemplate can perform both updates (insert, update, delete) via update() method and queries via query() methods.

E – False. JdbcTemplate does not generate SQL statements. It executes SQL strings provided by the developer. SQL generation is the responsibility of higher-level frameworks like Spring Data JDBC, JPA, or QueryDSL.

📚References Spring Framework Documentation – JdbcTemplate:
“JdbcTemplate executes SQL queries and updates, iterates over result sets, catches JDBC exceptions and translates them to the generic DataAccessException hierarchy.”

Spring JDBC – Exception Translation:
“All SQLException are translated to unchecked DataAccessException subclasses.”

VMware 2V0-72.22 Exam Guide – Data Access:
“Understand the role of JdbcTemplate, its methods for querying and updating, and the absence of checked SQLException.”
Question 19 Choose 2
Which two statements are true regarding the RestTemplate class? (Choose two.)
Show answerHide answer

Correct answer: B, C It automatically supports sending and receiving Java objects.It provides convenience methods for writing REST clients.

Explanation

Explanation:

RestTemplate is Spring's synchronous HTTP client for consuming RESTful services. It simplifies REST client development by providing convenience methods for common HTTP operations (GET, POST, PUT, DELETE, etc.) and automatically handles marshalling/unmarshalling between Java objects and HTTP messages (JSON/XML) using HttpMessageConverter.

B is correct – RestTemplate automatically supports sending and receiving Java objects. It uses HttpMessageConverter (e.g., MappingJackson2HttpMessageConverter) to convert request bodies to JSON/XML and responses back to Java objects without manual parsing.

C is correct – RestTemplate provides convenience methods for writing REST clients, such as getForObject(), getForEntity(), postForObject(), put(), delete(), exchange(), etc.

❌ Why other options are incorrect:

A – False. RestTemplate is synchronous and blocking. It waits for the response before proceeding. For non-blocking asynchronous HTTP clients, Spring provides WebClient (part of Spring WebFlux).

D – False. RestTemplate is for clients, not for writing REST services. Writing REST services is done using @RestController, @RequestMapping, etc. The phrase "convenience methods for writing REST services" describes Spring MVC on the server side.

E – False. RestTemplate does support custom headers. You can use HttpHeaders together with HttpEntity and pass to methods like exchange() or postForEntity() to set custom headers (e.g., authentication, content-type, custom keys).

📚 References

Spring Framework Documentation – RestTemplate:
“RestTemplate is a synchronous HTTP client that simplifies communication with RESTful services. It automatically converts between Java objects and HTTP messages.”

Spring Boot – REST Clients:
“RestTemplate provides methods like getForObject, postForLocation, and exchange for common HTTP interactions. Custom headers are supported via HttpEntity.”
Question 20 Choose 2
Which two statements are correct regarding the Health Indicator status? (Choose two.)
Show answerHide answer

Correct answer: C, D Custom status values can be created.The built-in status values are DOWN, OUT_OF_SERVICE, UNKNOWN, and UP in decreasing order of severity.

Explanation

Explanation:

Custom Status Values (Option C): Spring Boot Actuator's health architecture is highly extensible. Developers are not limited to the default statuses and can define completely custom status values (e.g., FATAL or DEGRADED) by instantiating a new Status object with a unique code string.

Built-in Statuses & Severity (Option D):
Out of the box, Spring Boot Actuator defines four core health statuses. They are ordered strictly by default severity to determine the aggregate health of the system: DOWN (highest severity), OUT_OF_SERVICE, UNKNOWN, and UP (lowest severity).

Why the Other Options Are Incorrect

A is incorrect: The first status in the sorted list of severity is selected as the overall system status, not the last. The aggregate health reflects the worst-case scenario present among the component metrics.

B is incorrect:The status with the highest severity (the most critical failure) is bubbling up to become the top-level aggregate status of the application.

E is incorrect: The default severity order is fully customizable. Developers can reconfigure the hierarchy using the application property management.endpoint.health.status.order to change the priority or include custom status values.

References

Spring Boot Production-ready Features Documentation:Section: Auto-configured HealthIndicators & Writing Custom HealthIndicators – Explains the default status severity ranking, how aggregation works, and how to define custom codes.
Full mock exam

Sit the 2V0-72.22 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real 2V0-72.22 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full 2V0-72.22 mock exam
  • 65questions per mock
  • 105 mintime limit
  • 79questions in the bank
  • Newmock on every attempt