Limited-Time Offer: Enjoy 50% Savings! Ends in 00h 00m 00s Coupon code: 50OFF
Skip to content

Free VMware Professional Develop VMware Spring 2V0-72.22 Exam Questions

Page: 1 / 8 Total 79 questions

Want more questions? Get Premium Access.

Question 1

Which statement describes the propagation behavior of Propagation.REQUIRES_NEW annotation? (Choose the best answer.)

Correct Answer: C. Starts a new transaction; if an active transaction already exists, it is suspended.

Question 2

Refer to the exhibit.

The above code shows a conditional @Bean method for the creation of a JdbcTemplate bean. Which two statements correctly describe the code behavior? (Choose two.)

Correct Answer: A. @ConditionalOnBean(name= ''dataSource'') should be replaced with @ConditionalOnBean (DataSource.class) for greater flexibility.; E. A JdbcTemplate bean will be created when a bean named dataSource has already been created.
Explanation:

The @Bean annotation is used to declare a method that returns an object that should be registered as a bean in the application context. The @ConditionalOnBean annotation is used to specify a condition for the bean creation based on the presence or absence of other beans in the application context. The name attribute of this annotation can be used to specify the bean name or names that must be present or absent for the condition to match. However, this approach is less flexible than using the value or type attribute, which can specify the bean class or classes that must be present or absent for the condition to match. Therefore, it is recommended to use @ConditionalOnBean(DataSource.class) instead of @ConditionalOnBean(name= ''dataSource'') for greater flexibility.

The JdbcTemplate class is a Spring class that simplifies the use of JDBC and helps to avoid common errors. It executes core JDBC workflow, leaving application code to provide SQL and extract results. To create a JdbcTemplate object, we need to pass a DataSource object as a constructor argument. The DataSource interface is a Java interface that represents a factory of connection objects. In this code, the jdbcTemplate() method takes a DataSource object as a parameter and returns a new JdbcTemplate object. This method is annotated with @Bean and @ConditionalOnBean(name= ''dataSource''), which means that it will only create a JdbcTemplate bean when there is already a bean named dataSource in the application context.


Question 3

Refer to the exhibit.

Which two statements are correct regarding auto-configuration of DataSource and JdbcTemplate beans given a Spring Boot application with only these two dependencies? (Choose two.)

Correct Answer: C. A JdbcTemplate bean will be auto-configured.; E. A DataSource bean will be auto-configured.

Question 4

Spring Boot will find and load property files in which of the following? (Choose the best answer.)

Correct Answer: C. application.properties or application.yml, usually located in the classpath root.

Question 5

What's the password storage format when using the DelegatingPasswordEncoder?

Correct Answer: B. {id}encodedPassword, where {id} is an identifier used to look up which PasswordEncoder should be used.
Explanation:

https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/crypto/password/DelegatingPasswordEncoder.html


Question 6

Which three types can be used as @Controller method arguments? (Choose three.)

Correct Answer: A. Locale; B. Principal; F. HttpSession
Explanation:

A . Locale

This is true because the Locale argument can be used to resolve the current locale that the client is using, based on the Accept-Language header or a cookie1.

B . Principal

This is true because the Principal argument can be used to access the currently authenticated user, if any1.

F . HttpSession

This is true because the HttpSession argument can be used to access the current session, if any1. Note that this argument is not required and will be null if a session does not exist.


Question 7

Refer to the exhibit.

How can a Spring Bean be created from this LegacySingleton class?

Correct Answer: A. Call LegacySingleton.getInstance() from within a @Bean method and return the instance.

Question 8

Which two are required to use transactions in Spring? (Choose two.)

Correct Answer: A. Add @EnableTransactionManagement to a Java configuration class.; B. Annotate a class, an interface, or individual methods requiring a transaction with the @Transactional annotation.
Explanation:

Transactions are units of work that ensure data consistency and integrity by enforcing atomicity, consistency, isolation, and durability (ACID) properties. Spring provides an abstraction layer for transaction management that supports various transaction APIs such as JDBC, JPA, Hibernate, etc. To use transactions in Spring, we need to do two things:

Enable transaction management by adding @EnableTransactionManagement annotation to a Java configuration class ortx:annotation-driven/element to an XML configuration file.

Declare transactional boundaries by annotating a class, an interface, or individual methods with the @Transactional annotation. This annotation indicates that the execution of the annotated element should be wrapped in a transaction.


Question 9

Refer to the exhibit.

AppConfig is a Java configuration class. Which two statements are true? (Choose two.)

Correct Answer: D. The bean is of type clientService and by default will be a Singleton.; E. The Java configuration can be profile specific by adding a @Profile annotation.

Question 10

Which two statements are true regarding @WebMvcTest? (Choose two.)

Correct Answer: A. It auto-configures a MockMvc.; D. Typically it is used in combination with @MockBean when there is a dependency bean to be mocked.