問題一覧
1
Which two statements about Spring MVC are true? (Choose two.)
Classes annotated with @Controller annotation can be detected by component scanning and loaded as Spring beans., Spring MVC requires a Servlet container; Spring Boot can embed Tomcat, Jetty, or Undertow.
2
Which two statements are true regarding a Spring Boot-based Spring MVC application? (Choose two.)
Spring Boot starts up an embedded servlet container by default. , The default embedded servlet container can be replaced with Undertow
3
Which two statements are true regarding Spring and Spring Boot Testing? (Choose two.)
Integration and slice testing are both supported, @SpringBootTest or @SpringJUnitConfig can be used for creating an ApplicationContext.
4
Spring Rest Template class
Can be used to send and receive HTTP data defined using Spring's RequestEntity and ResponseEntity.
5
Which two statements are true concerning constructor injection? (Choose two.)
If there is only one constructor the @Autowired annotation is not required., Constructor injection is preferred over field injection to support unit testing.
6
Which two statements are true regarding a Spring Boot "fat" JAR? (Choose two.)
The "fat" JAR contains compiled classes and dependencies that your code needs to run. , The fat JAR is created by the Spring Boot Maven plugin or Gradle plugin.
7
Spring bean classes are defined under a package called com.mycomp.service. What two options are required to enable component scanning? (Choose two.)
Ensure bean classes are annotated with the Component annotation. , Add the @ComponentScan("com.mycomp.service") to the Java configuration.
8
Which dependency enables an automatic restart of the application as code is changed during the development of a Spring Boot web application? (Choose the best answer.)
spring-boot-devtools
9
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.)
@Autowired private Foo foo; , @Autowired public void setFoo(@Qualifier("foo1") Foo foo) {...} , @Autowired @Qualifier("foo3") Foo foo;
10
Spring Transaction Management with AOP: Refer to the exhibit. public class ClientServiceImpl implements ClientService { @Transactional(propagation = Propagation.REQUIRED) public void update() { update2(); } @Transactional(propagation = Propagation.REQUIRES_NEW) public void update2() { } } Assume that the application is using Spring transaction management which uses Spring AOP internally. Choose the statement that describes what is happening when the update() method is called? (Choose the best answer.)
• There is only one transaction initiated by update() because the call to update2() does not go through the proxy.
11
Which two statements are correct regarding Spring Boot auto-configuration? (Choose two.)
Auto-configuration is applied by processing candidates listed in META-INF/spring factories. , Auto-configuration uses @Conditional annotations to constrain when it should apply.
12
Which two statements are true regarding storing user details in Spring Security? (Choose two.)
User details can be stored in a database, in LDAP, or in-memory. , User details can be stored in custom storage and retrieved by implementing the UserDetailsService interface.
13
Which two statements are true regarding Spring Boot Testing? (Choose two.)
@SpringBootTest without any configuration classes expects there is only one class annotated with @SpringBootConfiguration in the application. , @SpringBootTest is typically used for integration testing.
14
Which two statements are correct regarding Spring Boot 2.x Actuator Metrics? (Choose
Timer measures both the number of timed events and the total time of all events timed. , Custom metrics can be measured using Meter primitives such as Counter, Gauge, Timer, and DistributionSummary
15
Which two statements are true regarding @WebMvcTest? (Choose two.
It auto-configures a MockMvc., Typically it is used in combination with @MockBean when there is a dependency bean to be mocked.
16
Which is the correct approach to register for a bean destruction callback?
• Annotate the callback method with @PreDestroy.
17
Refer to the exhibit. @Configuration public class AppConfig { @Bean public ClientService clientService() { ClientServiceImpl clientService = new ClientServiceImpl(); clientService.addClientDao(new ClientDao()); return clientService; } } AppConfig is a Java configuration class. Which two statements are true? (Choose two.)
The Java configuration can be profile specific by adding a @Profile annotation. , The bean is of type clientService and by default will be a Singleton.
18
Spring puts each bean instance in a scope. What is the default scope? (Choose the best answer.)
singleton
19
Which two annotations indicate that the transaction for a transactional test method should be committed after the test method has completed? (Choose two.)
• @Rollback(false) , @Commit
20
What two options are auto-configured Spring Boot Actuator HealthIndicators? (Choose two.)
RabbitHealthIndicator, DataSourceHealthIndicator
21
Which following statements are true about Spring Data? (Choose two.)
Spring Data implementations exist for many data storage types, such as MongoDB, Neo4j, and Redis. , Spring Data can greatly reduce the amount of "boilerplate" code typically needed for data access.
22
Which statement describes the @AfterReturning advice type? (Choose the best answer.)
• The advice is invoked only if the method returns successfully but not if it throws an exception.
23
Which two options are valid optional attributes for Spring's @Transactional annotation? (Choose two.)
• isolation, • propagation
24
Refer to the exhibit. public class LegacySingleton { private static LegacySingleton instance; private LegacySingleton() { } public static LegacySingleton getInstance() { if (instance == null) { instance = new LegacySingleton(); } return instance; } } How can a Spring Bean be created from this LegacySingleton class?
• Call LegacySingleton.getInstance() from within a @Bean method and return the instance.
25
Refer to the exhibit. @Test @DirtiesContext public void testDirtiesContext() { }
• It will close the existing cached ApplicationContext and recreate a new one before the test method.
26
According to REST principles, which is the recommended way to update the order resource identified by 1234
• Send a PUT request to /orders/1234.
27
Using declarative transaction management, which situation will cause a transaction to roll back by default? Using declarative transaction management, which situation will cause a transaction to roll back by default?
• When any uncaught unchecked exception is thrown.
28
Refer to the exhibit. @RestController public class OrderController { @PutMapping("/store/orders/{id}") void update(@PathVariable String id, @RequestBody Order order) { } } How can a response status code be set for No Content (204)? (Choose the best answer.)
• Annotate the update() handler method with @ResponseStatus(HttpStatus.NO_CONTENT).
29
Which two options are application slices that can be tested with Spring Boot Testing? (Choose two.)
Repository, Web
30
Which statement is true?
• Methods annotated with @BeforeAll will run only once before any tests in a class are executed.
31
Which two statements are true about Spring Boot and Spring Data JPA? (Choose two.)
• @EntityScan and spring.jpa.* properties can be used customize Spring Data JPA., • Any kind of Hibernate property can be passed to Spring Data JPA like spring.jpa.properties.XXX.
32
Which three types of objects can be returned from a JdbcTemplate query? (Choose three.)
Generic MapS, User-defined types, Simple types (int, long, String, etc.)
33
Which two mechanisms of autowiring a dependency when multiple beans match the dependency's type are correct? (Choose two.)
Use of @Qualifier and @Autowired annotations together on a field., Use of @Qualifier and @Autowired annotations together with setter methods.
34
Which two statements about pointcut expressions are true? (Choose two.) Which two statements about pointcut expressions are true? (Choose two.)
• A pointcut expression can be used to select join points that have been annotated with a specific annotation., • A pointcut expression can include operators such as the following: && (and), || (or), ! (not).
35
Which two use cases can be addressed by the method-level security annotation @PreAuthorize? (Choose two.)
• Allow access to a method based on user identity., • Allow access to a method based on roles.
36
Which two annotations are meta-annotations on the @SpringBootApplication composed annotation? (Choose two.)
• @Configuration, • @ComponentScan
37
Which two statements are true about Spring Data JPA? (Choose two.)
Auto-configuration creates the needed Beans like DataSource and JpaTransactionManager., spring-boot-starter-data-jpa pulls in all necessary dependencies for Spring Data JPA.
38
Which two statements describe the ApplicationContext correctly? (Choose two.
• The ApplicationContext maintains singleton beans that are instantiated by the Spring runtime interface., • The ApplicationContext can be created in a test environment, web application, and in a standalone application.
39
Refer to the exhibit. @Configuration public class MyConfig { @Bean public AccountRepository accountRepository() { return new JdbcAccountRepository(); } @Bean public TransferServiceImpl transferService() { TransferServiceImpl service = new TransferServiceImpl(); service.setAccountRepository(accountRepository()); return service; } @Bean public AccountServiceImpl accountService() { return new AccountServiceImpl(accountRepository()); } } Based on the default Spring behavior, choose the correct answer. (Choose the best answer.)
One AccountRepository bean will be instantiated since the default scope is singleton.
40
Which three types can be used as @Controller method arguments? (Choose three.)
Locale , httpSession, Principal
41
Refer to the exhibit. @PutMapping ("/accounts/{id}") public void update () () Which option is a valid way to retrieve the account id? (Choose the best answer.)
Add @PathVariable("id") String accountid argument to the update() handler method.
42
What Spring Boot Starter can be used for a Spring REST Application?
spring-boot-starter-web
43
Which two statements are true regarding the RestTemplate class? (Choose two.)
It automatically supports sending and receiving Java objects. , It provides convenience methods for writing REST clients.
44
Which statement is true? (Choose the best answer.)
@ActiveProfiles is a class-level annotation that is used to declare which bean definition profiles should be active when loaded an ApplicationContext for an integration test.
45
Which two statements are true about @Controller annotated classes? (Choose two.)
The classes are eligible for handling requests in Spring MVC. , The @Controller annotation is a stereotype annotation like @Component.
46
1 Spring Boot will find and load property files in which of the following? (Choose the best answer.)
application.properties or application.yml, usually located in the classpath root.
47
Which three dependencies are provided by the spring-boot-starter-test? (Choose three)
jUnit, spring-test, hamcrest
48
What's the password storage format when using the DelegatingPasswordEncoder?
(id)encodedPassword, where (id) is an identifier used to look up which PasswordEncoder should be used.
49
Refer to the exhibit. @Entity public class Customer { @Id private Long id; private String name; private Date orderDate; private String email; Which two methods will be implemented at runtime if declared in a Spring Data JPA Repository? (Choose two.)
public Customer findByEmail (String email); , public Customer findFirstByOrderDateBetween (Date d1, Date d2);
50
Which type of advice can be used to stop an exception propagating up the stack, and to return an error value instead?
@Around
51
Refer to the exhibit. @Configuration public class AppConfig ( @Bean public ClientService clientService() ( return new ClientServiceImpl(); } } What is the id/name of the declared bean in this Java configuration class? (Choose the best answer.)
clientService (starting with lowercase "c")
52
Which two statements are true about REST? (Choose two.)
REST is Reliable. , REST is Interoperable.