Question 6 of 74

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

    Correct Answer: A, C

    In a Spring Boot-based Spring MVC application, the default embedded servlet container can be replaced with Undertow. This is achieved by configuring the project dependencies accordingly. Additionally, Spring Boot starts up an embedded servlet container by default to serve the web application. The default servlet container is Tomcat, but it can be replaced with other options like Jetty or Undertow if desired.

Question 7 of 74

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

    Correct Answer: B, E

    Both @SpringBootTest and @SpringJUnitConfig annotations can be used for creating an ApplicationContext in Spring and Spring Boot testing. Additionally, Spring and Spring Boot support both integration testing and slice testing. Integration testing can be done using annotations such as @SpringBootTest, whereas slice testing can be performed using specialized annotations like @WebMvcTest, @DataJpaTest among others, which load only parts of the application context.

Question 8 of 74

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

    Correct Answer: D

    When the update1() method is called, it starts a transaction due to the @Transactional annotation with Propagation.REQUIRED. Within this transaction, the update2() method is called. Although update2() has a @Transactional annotation with Propagation.REQUIRES_NEW, it does not create a new transaction because the call to update2() is an internal method call within the same class. Spring AOP proxies only apply to external method calls, so the call to update2() does not go through the proxy. Therefore, only one transaction is initiated by update1().

Question 9 of 74

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

    Correct Answer: A, C

    Constructor injection is preferred over field injection to support unit testing because it makes dependencies explicit and easier to manage. Also, if there is only one constructor, the @Autowired annotation is not required, as the dependency injection framework can automatically use that constructor without additional annotations.

Question 10 of 74

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

    Correct Answer: B, C, E

    Given an ApplicationContext containing three beans of type Foo with identifiers foo1, foo2, and foo3, the valid @Autowired scenarios are those that specifically distinguish between these beans using the @Qualifier annotation or unique names. Using @Qualifier ensures that a specific bean is injected, avoiding conflicts that arise when multiple beans of the same type exist. Therefore, the scenarios with the annotations @Autowired @Qualifier ("foo3") Foo foo (B), @Autowired public void setFoo (@Qualifier ("foo1") Foo foo) {…} (C), and @Autowired private Foo foo2 (E) are valid as they correctly specify which bean to inject. This ensures the ApplicationContext initializes without errors, injecting all three beans foo1, foo2, and foo3 correctly.