Exam4Training

VMware 2V0-72.22 Professional Develop VMware Spring Online Training

Question #1

Which two statements are true regarding Spring Boot Testing? (Choose two.)

  • A . @TestApplicationContext is used to define additional beans or customizations for a test.
  • B . Test methods in a @SpringBootTest class are transactional by default.
  • C . @SpringBootTest is typically used for integration testing.
  • D . Test methods annotated with @SpringBootTest will recreate the ApplicationContext.
  • E . @SpringBootTest without any configuration classes expects there is only one class annotated with@SpringBootConfiguration in the application.

Reveal Solution Hide Solution

Correct Answer: C,D
Question #2

Which two use cases can be addressed by the method level security annotation @PreAuthorize? (Choose two.)

  • A . Allow access to a method based on user identity.
  • B . Allow access to a method based on the returned object.
  • C . Allow access to a method based on HTTP method.
  • D . Allow access to a method based on request URL.
  • E . Allow access to a method based on roles.

Reveal Solution Hide Solution

Correct Answer: C,E
C,E

Explanation:

Reference: https://docs.spring.io/spring-security/site/docs/5.2.11.RELEASE/reference/html/authorization.html

Question #3

Which two statements are true regarding a Spring Boot-based Spring MVC application? (Choose two.)

  • A . The default embedded servlet container can be replaced with Undertow.
  • B . Jetty is the default servlet container.
  • C . Spring Boot starts up an embedded servlet container by default.
  • D . The default port of the embedded servlet container is 8088.
  • E . Spring MVC starts up an in-memory database by default.

Reveal Solution Hide Solution

Correct Answer: B,C
B,C

Explanation:

Reference: https://www.javatpoint.com/spring-vs-spring-boot-vs-spring-mvc

Question #4

What are the two reasons Spring be used to build a Java application? (Choose two.)

  • A . Spring automates a Java application build.
  • B . Spring provides a Dependency Injection container.
  • C . Spring automates deployment of Java applications to all of the major cloud providers.
  • D . Spring provides comprehensive Java IDE support.
  • E . Spring provides abstractions over infrastructure such as persistence and messaging.

Reveal Solution Hide Solution

Correct Answer: A,B
A,B

Explanation:

Reference: https://spring.io/why-spring

Question #5

Which two statements are correct regarding the @EnableAutoConfiguration annotation? (Choose two.)

  • A . It is a meta-annotation on the @SpringBootApplication composed annotation.
  • B . It enables auto-configuration of the ApplicationContext by attempting to guess necessary beans.
  • C . It is meta-annotation on the @SpringBootConfiguration composed annotation.
  • D . It has the same effect regardless of the package of the class that is annotated with it.
  • E . It ensures auto-configuration is applied before user-defined beans have been registered.

Reveal Solution Hide Solution

Correct Answer: A,D
A,D

Explanation:

Reference: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html

Question #6

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

  • A . Add @EnableTransactionManagement to a Java configuration class.
  • B . Annotate a class, an interface, or individual methods requiring a transaction with the @Transactional annotation.
  • C . A class must be annotated with @Service and @Transaction.
  • D . A class requiring a transaction must implement the TransactionInterceptor interface.
  • E . Write a Spring AOP advice to implement transactional behavior.

Reveal Solution Hide Solution

Correct Answer: A,B
A,B

Explanation:

Reference: https://www.baeldung.com/transaction-configuration-with-jpa-and-spring

Question #7

Refer to the exhibit.

Which two statements are correct regarding the HelloAutoConfig auto-configuration class when it is specified in the META-INF/spring.factories file? (Choose two.)

  • A . A HelloService bean will be created from the helloService() method even if the HelloService.class is not in the classpath.
  • B . A HelloService bean will be created from the helloService() method only when there is no other HelloService bean in the ApplicationContext.
  • C . This auto-configuration class is used only when the HelloService.class is not on the classpath.
  • D . This auto-configuration class is used only when the HelloService.class is on the classpath.
  • E . A HelloService bean will be created from the helloService() method and will replace existing a HelloService bean in the ApplicationContext.

Reveal Solution Hide Solution

Correct Answer: B,D
Question #8

Which two statements are true regarding bean creation? (Choose two.)

  • A . A Spring bean can be explicitly created by annotating methods or fields by @Autowired.
  • B . A Spring bean can be implicitly created by annotating the class with @Component and using the component-scanner to scan its package.
  • C . A Spring bean can be implicitly created by annotating the class with @Bean and using the component- scanner to scan its package.
  • D . A Spring bean can be explicitly created using @Bean annotated methods within a Spring configuration class.
  • E . A Spring bean can be explicitly created by annotating the class with @Autowired.

Reveal Solution Hide Solution

Correct Answer: B,E
B,E

Explanation:

Reference:

https://docs.spring.io/spring-framework/docs/3.0.0.M4/spring-framework-reference/html/ch03s10.html

https://howtodoinjava.com/spring-core/spring-beans-autowiring-concepts/

Question #9

Which statement defines a pointcut? (Choose the best answer.)

  • A . A point in the execution of a program such as a method call or field assignment.
  • B . An expression that selects one or more join points.
  • C . A module that encapsulated advices.
  • D . Code to be executed at each selected join point.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

Reference: https://www.baeldung.com/spring-aop-pointcut-tutorial

Question #10

Which two statements are correct regarding the Health Indicator status? (Choose two.)

  • A . The last status in a sorted list of HealthIndicators is used to derive the final system health.
  • B . The status with the least severity is used as the top-level status.
  • C . Custom status values can be created.
  • D . The built-in status values are DOWN, OUT_OF_SERVICE, UNKNOWN, and UP in decreasing order of severity.
  • E . The severity order cannot be changed due to security reasons.

Reveal Solution Hide Solution

Correct Answer: C,D
C,D

Explanation:

Reference: https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/production-ready-endpoints.html

Question #11

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

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

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

Reference: https://developer.ibm.com/tutorials/j-spring-boot-basics-perry/

Question #12

Which option is true about use of mocks in a Spring Boot web slice test? (Choose the best answer.)

  • A . Mocking a Spring Bean requires annotating it with @MockBean annotation.
  • B . If a Spring Bean already exists in the web slice test spring context, it cannot be mocked.
  • C . Mocks cannot be used in a Spring Boot web slice test.
  • D . Mocking a Spring Bean requires annotating it with @Mock annotation.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Reference: https://tanzu.vmware.com/developer/guides/spring-boot-testing/

Question #13

What two options are auto-configured Spring Boot Actuator HealthIndicators? (Choose two.)

  • A . DataSourceHealthIndicator
  • B . GoogleCloudDataStoreHealthIndicator
  • C . DynamoDBHealthIndicator
  • D . RabbitHealthIndicator
  • E . OktaHealthIndicator

Reveal Solution Hide Solution

Correct Answer: A,D
A,D

Explanation:

Reference: https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/production-ready-endpoints.html

Question #14

Which two statements are correct regarding Spring Boot 2.x Actuator Metrics? (Choose two.)

  • A . An external monitoring system must be used with Actuator.
  • B . The metrics endpoint /actuator/metrics is exposed over HTTP by default.
  • C . Timer measures both the number of timed events and the total time of all events timed.
  • D . Custom metrics can be measured using Meter primitives such as Counter, Gauge, Timer, and Distribution Summary.
  • E . A metric must be created with one or more tags.

Reveal Solution Hide Solution

Correct Answer: A,B
Question #15

Which two statements describe Spring JdbcTemplate? (Choose two.)

  • A . All JdbcTemplate methods throw SQLException which you are required to handle.
  • B . The JdbcTemplate provides the ability to work with result sets.
  • C . The JdbcTemplate can only perform update but not insert to the database.
  • D . The JdbcTemplate provides methods for query execution.
  • E . The JdbcTemplate generates SQL statements.

Reveal Solution Hide Solution

Correct Answer: B,E
B,E

Explanation:

Reference: https://www.baeldung.com/spring-jdbctemplate-in-list

Question #16

Which statement describes the @AfterReturning advice type? (Choose the best answer.)

  • A . The advice is invoked only if the method returns successfully but not if it throws an exception.
  • B . The @AfterReturning advice allows behavior to be added after a method returns even if it throws an exception.
  • C . The advice has complete control over the method invocation; it could even prevent the method from being called at all.
  • D . Typically used to prevent any exception, thrown by the advised method, from propagating up the call-stack.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Reference: https://www.amitph.com/spring-aop-afterreturning-advice

Question #17

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

  • A . TestEntityManager provides all methods that are provided by EntityManager and more.
  • B . If an embedded database is on the classpath, it will be used to configure a DataSource by default.
  • C . It can be used for testing both JPA components and NoSQL components.
  • D . It auto-configures a TestEntityManager bean.
  • E . It can be used for testing JdbcTemplate.

Reveal Solution Hide Solution

Correct Answer: B,D
B,D

Explanation:

Reference: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.html

Question #18

Refer to the exhibit.

How can a response status code be set for No Content (204)? (Choose the best answer.)

  • A . Annotate the update() handler method with @PutMapping(“/store/orders/{id”}”, HttpStatus.NO_CONTENT).
  • B . Annotate the update() handler method with @ResponseStatus(HttpStatus.NO_CONTENT).
  • C . Annotate the update() handler method with @ResponseEntity(204).
  • D . The update() handler method cannot return a void type, it must return a ResponseEntity type.

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

Reference: https://stackoverflow.com/questions/55691288/is-this-the-correct-way-to-return-204-no-content- using-spring

Question #19

Which three statements are advantages of using Spring’s Dependency Injection? (Choose three.)

  • A . Dependency injection can make code easier to trace because it couples behavior with construction.
  • B . Dependency injection reduces the start-up time of an application.
  • C . Dependencies between application components can be managed external to the components.
  • D . Configuration can be externalized and centralized in a small set of files.
  • E . Dependency injection creates tight coupling between components.
  • F . Dependency injection facilitates loose coupling between components.

Reveal Solution Hide Solution

Correct Answer: B,D,E
B,D,E

Explanation:

Reference: https://raviroza.com/tight-coupling-and-loose-coupling-in-spring-framework/

Question #20

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

  • A . Locale
  • B . Principal
  • C . Language
  • D . Session
  • E . Request
  • F . HttpSession

Reveal Solution Hide Solution

Correct Answer: A,E,F
A,E,F

Explanation:

Reference: https://docs.spring.io/spring-framework/docs/3.0.0.M4/spring-framework-reference/html/ch15s03.html

Exit mobile version