ExamGecko
Home Home / VMware / 2V0-72.22

VMware 2V0-72.22 Practice Test - Questions Answers

Question list
Search
Search

Question 1

Report
Export
Collapse

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

A.
Ensure a valid bean name in the @Component annotation is specified.
A.
Ensure a valid bean name in the @Component annotation is specified.
Answers
B.
Ensure a valid @ComponentScan annotation in the Java configuration is specified.
B.
Ensure a valid @ComponentScan annotation in the Java configuration is specified.
Answers
C.
Ensure a valid @Scope for the class is specified.
C.
Ensure a valid @Scope for the class is specified.
Answers
D.
Ensure a valid @Bean for the class is specified.
D.
Ensure a valid @Bean for the class is specified.
Answers
Suggested answer: B

Explanation:

The @Component annotation indicates that a class is a candidate for auto-detection by Spring and can be registered as a bean in the application context. However, to enable this feature, the Java configuration class must also have the @ComponentScan annotation, which tells Spring where to look for annotated components.

asked 16/09/2024
Arash Rind
42 questions

Question 2

Report
Export
Collapse

Which two options will inject the value of the daily.limit system property? (Choose two.)

A.
@Value(“#{daily.limit}”)
A.
@Value(“#{daily.limit}”)
Answers
B.
@Value(“$(systemProperties.daily.limit)”)
B.
@Value(“$(systemProperties.daily.limit)”)
Answers
C.
@Value(“$(daily.limit)”)
C.
@Value(“$(daily.limit)”)
Answers
D.
@Value(“#{systemProperties[‘daily.limit’]}”)
D.
@Value(“#{systemProperties[‘daily.limit’]}”)
Answers
E.
@Value(“#{systemProperties.daily.limit}”)
E.
@Value(“#{systemProperties.daily.limit}”)
Answers
Suggested answer: C, D

Explanation:

The @Value annotation can be used to inject values from external sources into fields, constructor parameters, or method parameters. To inject a system property, the annotation can use either the ${...} placeholder syntax or the #{...} SpEL expression syntax. The former is simpler and more concise, while the latter is more powerful and flexible. Both syntaxes can access the systemProperties map, which contains all the system properties as key-value pairs.

asked 16/09/2024
Felix Imafidon
31 questions

Question 3

Report
Export
Collapse

Which two options are REST principles? (Choose two.)

A.
RESTful applications use a stateless architecture.
A.
RESTful applications use a stateless architecture.
Answers
B.
RESTful application use HTTP headers and status codes as a contract with the clients.
B.
RESTful application use HTTP headers and status codes as a contract with the clients.
Answers
C.
RESTful applications cannot use caching.
C.
RESTful applications cannot use caching.
Answers
D.
RESTful application servers keep track of the client state.
D.
RESTful application servers keep track of the client state.
Answers
E.
RESTful applications favor tight coupling between the clients and the servers.
E.
RESTful applications favor tight coupling between the clients and the servers.
Answers
Suggested answer: A, B

Explanation:

REST stands for Representational State Transfer, which is an architectural style for designing web services that adhere to certain principles. One of these principles is statelessness, which means that each request from a client to a server must contain all the information necessary to understand the request, and that no session state is maintained on the server side. Another principle is uniform interface, which means that clients and servers communicate using a standardized protocol, such as HTTP, and use its features, such as headers and status codes, to exchange information about the resources and their representations.

asked 16/09/2024
Andy Hodges
39 questions

Question 4

Report
Export
Collapse

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.
A.
Mocking a Spring Bean requires annotating it with @MockBean annotation.
Answers
B.
If a Spring Bean already exists in the web slice test spring context, it cannot be mocked.
B.
If a Spring Bean already exists in the web slice test spring context, it cannot be mocked.
Answers
C.
Mocks cannot be used in a Spring Boot web slice test.
C.
Mocks cannot be used in a Spring Boot web slice test.
Answers
D.
Mocking a Spring Bean requires annotating it with @Mock annotation.
D.
Mocking a Spring Bean requires annotating it with @Mock annotation.
Answers
Suggested answer: A

Explanation:

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

asked 16/09/2024
hesham azarkan
44 questions

Question 5

Report
Export
Collapse

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

A.
Access control can be configured at the method level.
A.
Access control can be configured at the method level.
Answers
B.
A special Java Authentication and Authorization Service (JAAS) policy file needs to be configured.
B.
A special Java Authentication and Authorization Service (JAAS) policy file needs to be configured.
Answers
C.
Authentication data can be accessed using a variety of different mechanisms, including databases and LDAP.
C.
Authentication data can be accessed using a variety of different mechanisms, including databases and LDAP.
Answers
D.
In the authorization configuration, the usage of permitAll () allows bypassing Spring security completely.
D.
In the authorization configuration, the usage of permitAll () allows bypassing Spring security completely.
Answers
E.
It provides a strict implementation of the Java EE Security specification.
E.
It provides a strict implementation of the Java EE Security specification.
Answers
Suggested answer: A, C

Explanation:

Spring Security is a framework that provides comprehensive security services for Java applications, such as authentication, authorization, encryption, session management, and more. One of its features is method security, which allows applying access control rules at the method level using annotations or XML configuration. Another feature is authentication, which is the process of verifying the identity of a user or a system. Spring Security supports various authentication mechanisms, such as username and password, tokens, certificates, etc., and can access authentication data from different sources, such as databases, LDAP directories, in-memory stores, etc.

asked 16/09/2024
Simone Mento
28 questions

Question 6

Report
Export
Collapse

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.
A.
The default embedded servlet container can be replaced with Undertow.
Answers
B.
Jetty is the default servlet container.
B.
Jetty is the default servlet container.
Answers
C.
Spring Boot starts up an embedded servlet container by default.
C.
Spring Boot starts up an embedded servlet container by default.
Answers
D.
The default port of the embedded servlet container is 8088.
D.
The default port of the embedded servlet container is 8088.
Answers
E.
Spring MVC starts up an in-memory database by default.
E.
Spring MVC starts up an in-memory database by default.
Answers
Suggested answer: A, C

Explanation:

Spring Boot provides a convenient way to create Spring MVC applications with minimal configuration. By default, it uses Tomcat as the embedded servlet container, but it also supports other containers such as Jetty and Undertow. To use a different container, we just need to exclude the spring-boot-starter-tomcat dependency and include the corresponding starter for the desired container

asked 16/09/2024
Vijayakumar Dhandapani
42 questions

Question 7

Report
Export
Collapse

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

A.
EasyMock is supported out of the box.
A.
EasyMock is supported out of the box.
Answers
B.
@SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext.
B.
@SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext.
Answers
C.
Mockito spy is not supported in Spring Boot testing by default.
C.
Mockito spy is not supported in Spring Boot testing by default.
Answers
D.
The spring-test dependency provides annotations such as @Mock and @MockBean.
D.
The spring-test dependency provides annotations such as @Mock and @MockBean.
Answers
E.
Integration and slice testing are both supported.
E.
Integration and slice testing are both supported.
Answers
Suggested answer: B, E

Explanation:

Spring and Spring Boot provide various annotations and utilities to support testing of different layers of the application. To create an ApplicationContext for integration tests, we can use either @SpringBootTest or @SpringJUnitConfig annotations. The former is a specialized annotation that also provides additional features such as auto-configuration, web environment emulation, and test properties management. The latter is a general-purpose annotation that combines @ContextConfiguration and @ExtendWith(SpringExtension.class) annotations.

To perform slice testing, which focuses on testing a specific layer or feature of the application in isolation, we can use annotations such as @WebMvcTest, @DataJpaTest, @RestClientTest, etc. These annotations will only load the relevant beans for the tested slice and mock or stub the other dependencies.

 

asked 16/09/2024
Prakhar Sengar
33 questions

Question 8

Report
Export
Collapse

Refer to the exhibit.

Assume that the application is using Spring transaction management which uses Spring AOP internally.

Choose the statement that describes what is happening when the update1 method is called?

(Choose the best answer.)

A.
There are 2 transactions because REQUIRES_NEW always runs in a new transaction.
A.
There are 2 transactions because REQUIRES_NEW always runs in a new transaction.
Answers
B.
An exception is thrown as another transaction cannot be started within an existing transaction.
B.
An exception is thrown as another transaction cannot be started within an existing transaction.
Answers
C.
There is only one transaction because REQUIRES_NEW will use an active transaction if one already exists.
C.
There is only one transaction because REQUIRES_NEW will use an active transaction if one already exists.
Answers
D.
There is only one transaction initiated by update1() because the call to update2() does not go through the proxy.
D.
There is only one transaction initiated by update1() because the call to update2() does not go through the proxy.
Answers
Suggested answer: D

Explanation:

When using Spring transaction management with annotation-driven mode, the @Transactional annotation will be processed by a TransactionInterceptor that implements the AOP advice interface. This interceptor will be applied to the target bean through a proxy that implements the same interface as the target bean. Therefore, when a method of the target bean is called from outside, it will actually invoke the proxy method, which will delegate to the interceptor and then to the actual target method.

However, when a method of the target bean is called from within the same bean, it will not go through the proxy and thus bypass the interceptor logic. In this case, when update1() calls update2(), it will not start a new transaction as specified by REQUIRES_NEW propagation level, but rather join the existing transaction initiated by update1() itself.

asked 16/09/2024
Daniel williams
51 questions

Question 9

Report
Export
Collapse

Which two statements are true concerning constructor injection? (Choose two.)

A.
If there is only one constructor the @Autowired annotation is not required.
A.
If there is only one constructor the @Autowired annotation is not required.
Answers
B.
Constructor injection only allows one value to be injected.
B.
Constructor injection only allows one value to be injected.
Answers
C.
Constructor injection is preferred over field injection to support unit testing.
C.
Constructor injection is preferred over field injection to support unit testing.
Answers
D.
Construction injection can be used with multiple constructors without @Autowired annotation.
D.
Construction injection can be used with multiple constructors without @Autowired annotation.
Answers
E.
Field injection is preferred over constructor injection from a unit testing standpoint.
E.
Field injection is preferred over constructor injection from a unit testing standpoint.
Answers
Suggested answer: A, C

Explanation:

Constructor injection is one of the ways to inject dependencies into a bean using its constructor parameters. Since Spring 4.3, if a bean has only one constructor, the @Autowired annotation can be omitted and Spring will use that constructor by default.

Constructor injection is generally recommended over field injection because it makes the dependencies of a bean explicit and immutable. It also facilitates unit testing because it allows us to easily provide mock dependencies through constructor arguments.

asked 16/09/2024
Charles Smith
28 questions

Question 10

Report
Export
Collapse

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

A.
@Autowired public void setFoo (Foo foo) {…}
A.
@Autowired public void setFoo (Foo foo) {…}
Answers
B.
@Autowired @Qualifier (“foo3”) Foo foo;
B.
@Autowired @Qualifier (“foo3”) Foo foo;
Answers
C.
@Autowired public void setFoo (@Qualifier (“foo1”) Foo foo) {…}
C.
@Autowired public void setFoo (@Qualifier (“foo1”) Foo foo) {…}
Answers
D.
@Autowired private Foo foo;
D.
@Autowired private Foo foo;
Answers
E.
@Autowired private Foo foo2;
E.
@Autowired private Foo foo2;
Answers
F.
@Autowired public void setFoo(Foo foo2) {…}
F.
@Autowired public void setFoo(Foo foo2) {…}
Answers
Suggested answer: B, C, F

Explanation:

The @Autowired annotation can be used to inject a dependency into a field, a constructor, or a setter method. However, if there are multiple beans of the same type in the application context, Spring will not be able to determine which one to inject by default. To resolve this ambiguity, we can use the @Qualifier annotation to specify the bean id of the desired dependency. Alternatively, we can use the bean id as the name of the field or the parameter of the setter method, and Spring will match it with the corresponding bean.

asked 16/09/2024
R. M.
33 questions
Total 79 questions
Go to page: of 8