2V0-72.22 Practice Test

2V0-72.22 Practice Test practice questions, page 4 of 4, with answer review and explanations.

Question 16

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.)

  1. @ConditionalOnBean(name= “dataSource”) should be replaced with @ConditionalOnBean (DataSource.class) for greater flexibility.
  2. @ConditionalOnBean(name= “dataSource”) should be replaced with @ConditionalOnMissingBean (DataSource.class) for greater flexibility.
  3. The @Bean annotation should be removed.
  4. A JdbcTemplate bean will be created when the DataSource class is in the classpath but there is no DataSource bean.
  5. A JdbcTemplate bean will be created when a bean named dataSource has already been created.

Question 17

What is a Spring Boot starter dependency? (Choose the best answer.)

  1. A setting for specifying which code you want Spring Boot to generate for you.
  2. A specific POM which you must build to control Spring Boot’s opinionated runtime.
  3. A pre-existing model project you can download and use as the basis of your project.
  4. An easy way to include multiple, coordinated dependencies related to a specific technology, like web or JDBC.

Question 18

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

  1. Add @EnableTransactionManagement to a Java configuration class.
  2. Annotate a class, an interface, or individual methods requiring a transaction with the @Transactional annotation.
  3. A class must be annotated with @Service and @Transaction.
  4. A class requiring a transaction must implement the TransactionInterceptor interface.
  5. Write a Spring AOP advice to implement transactional behavior.