Frage 1
Frage
Given the following Spring configuration file, what is the correct answer:
<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository.JpaDao"/>
Antworten
-
The first declared bean MyServiceImpl is missing an id must be named myService
-
The second declared bean JpaDao is missing an id must be named jpaDao
-
Answers 1 and 2 are both rights
-
Answers 1 and 2 are both wrong
Frage 2
Frage
Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>
Antworten
-
The p namespace has to be declared
-
Bean id is bankServiceImpl
-
The BankServiceImpl references a NationalBank bean
-
NationalBank is a scalar value
Frage 3
Frage
What the name of the bean defined in the following configuration class? Select a single answer.
@Configuration
public class ApplicationConfig {
@Autowired
private DataSource dataSource;
@Bean
ClientRepository clientRepository() {
ClientRepository accountRepository = new JpaClientRepository();
accountRepository.setDataSource(dataSource);
return accountRepository;
}
}
Frage 4
Frage
How could you externalize constants from a Spring configuration file or a Spring annotation into a .properties file? Select one or more answers
Antworten
-
By using the <util:constant /> tag
-
By declaring the ConstantPlaceholderConfigurer bean post processor
-
By using the <context:property-placeholder /> tag
-
By using the c: namespace
Frage 5
Frage
What statement is not correct in live environment? Select a unique answer.
Antworten
-
Constuctor and properties autowiring in the same bean are not compatible
-
A bean should have a default or a no-args constructor
-
The <constructor-arg> tag could take type, name and index to reduce ambiguity
-
None of the above
-
All of the above
Frage 6
Frage
What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy annotations?
Antworten
-
Those annotations are specified in the JSR-250
-
The Spring Framework embedded those annotations
-
The <context:component-scan> tag enable them
-
The <context:annotation-config > tag enable them
-
Declaring the CommonAnnotationBeanPostProcessor enable them
Frage 7
Frage
What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?
Frage 8
Frage
Select the right statement about referring a Spring configuration file inside the package com.example.myapp in the below example?
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");
Antworten
-
The classpath: prefix could be omitted
-
Package name using the dot character is not well formatted
-
The slash character preceding com.example could be omit
-
All of the above
-
None of the above
Frage 9
Frage
How to auto-inject into a field a Spring bean by its name? Select one or more answer choices.
Antworten
-
With the name attribute of the @Autowired annotation
-
By using the single @Qualifier annotation
-
By using both the @Autowired and the @Qualifier Spring annotations
-
By using the @Autowired annotation and naming the field with the bean name
Frage 10
Frage
What are the main advantages of using interfaces when designing business services? Select one or more answer choices.
Antworten
-
Mocking or stubbing the service
-
Be able to use the Spring auto-injection
-
Can do dependency checking
-
Loosely coupled code
Frage 11
Frage
Select one or many correct answers about Spring bean life cycle.
Antworten
-
The method annotated with @PostConstruct is called after bean instantiation and before properties setting of the bean
-
The method @PreDestroy of a prototype bean is called when the bean is garbage collected
-
1. The init() method declared in the init-method attribute of a bean is called before the afterPropertiesSet callback method of the InitializingBean interface
-
1. The method annotated with @PostConstruct is called before the afterPropertiesSet callback method of the InitializingBean interface
Frage 12
Frage
Given the following configuration class, what are the correct affirmations? Select one or more answers.
public class ApplicationConfig {
private DataSource dataSource;
@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}
Frage 13
Frage
What are the features of the XML <context:namespace? Select one or many answers.
Antworten
-
@Transactional annotation scanning
-
@Aspect annotation detection enabling
-
@Autowired annotation enabling
-
@Component annotation scanning
Frage 14
Frage
Select one or more correct statements about developing integration test with Spring support.
Antworten
-
A new Spring context is created for each test class
-
To get a reference on the bean you want to test, you have to call the getBean() method of the Spring context
-
Spring context configuration could be inherited from the super class
-
1. The Spring context configuration file has to be provided to the @ContextConfiguration annotation
Frage 15
Frage
What are the main advantage(s) for using Spring when writing integration tests?
Frage 16
Frage
What are the main advantage(s) for using Spring when writing unit tests?
Frage 17
Frage
What is right about the Spring test module?
Antworten
-
It provides an abstraction layer for the main open source mock frameworks
-
Provides the @Mock annotation
-
It dynamically generates mock objects
-
All of the above
-
None of the above
Frage 18
Frage
Select correct statement(s) about transactional support of the Spring test module.
Antworten
-
Transaction manager could be set within the @TransactionConfiguration annotation
-
Method annotated with @Before is executed outside of the test’s transaction
-
Spring test may rollback the transaction of a service configured with the REQUIRES_NEW propagation
-
The transaction of a method annotated with the @Rollback annotation with its default values is rolled back after the method has completed
Frage 19
Frage
Considering 2 classes AccountServiceImpl and ClientServiceImpl. Any of these 2 classes inherits from each other. What is the result of the following pointcut expression?
execution(* *..AccountServiceImpl.update(..))
&& execution(* *..ClientServiceImpl.update(..))
Antworten
-
Matches public update methods of the 2 classes, whatever the arguments
-
Matches any update methods of the 2 classes, whatever the arguments and method visibility
-
Matches any update methods of the 2 classes, with one more arguments and whatever method visibility
-
No joint point is defined
Frage 20
Frage
Using the Spring AOP framework, what is the visibility of the method matches by the following join point?
@Pointcut("execution(* *(..))")
private void anyOperation() {};
Antworten
-
All methods, whereas their visibility
-
All methods, except private method
-
Protected and public methods
-
Public methods
Frage 21
Frage
What are the 2 correct statements about AOP proxy?
Antworten
-
AOP proxies are created by Spring in order to implement the aspect contracts
-
AOP proxies are always created with a JDK dynamic proxy
-
Only classes that implements a least one interface could be proxied
-
All methods could be proxied
-
Proxies are created by a BeanPostProcessor
Frage 22
Frage
What is an after throwing advice? Select a unique answer.
Antworten
-
Advice that could throw an exception
-
Advice to be executed if a method exits by throwing an exception
-
Advice that executes before a join point
-
Spring does not provide this type of advice
Frage 23
Frage
What is an after returning advice? Select a unique answer.
Antworten
-
Advice to be executed regardless of the means by which a join point exits
-
Advice that surrounds a method invocation and can perform custom behavior before and after the method invocation
-
Advice to be executed before method invocation
-
Advice to be executed after a join point completes without throwing an exception
Frage 24
Frage
What is an advice? Select a unique answer.
Antworten
-
An action taken by an aspect at a particular join point
-
A point during the execution of a program
-
An aspect and a pointcut
-
A predicate that matches join points
Frage 25
Frage
What is a pointcut? Select the single answer.
Antworten
-
Code to execute at a join point
-
An expression to identify joinpoints
-
An advice and a jointpoint
-
None of the above
Frage 26
Frage
Select method’s signatures that match with the following pointcut:
execution(* com.test.service..*.*(*))
Antworten
-
void com.test.service.MyServiceImpl#transfert(Money amount)
-
void com.test.service.MyServiceImpl#transfert(Account account, Money amount)
-
void com.test.service.account.MyServiceImpl#transfert(Money amount)
-
void com.test.service.account.MyServiceImpl#transfert(Account account, Money amount)
-
None of the above
Frage 27
Frage
What are the unique right answer about Spring AOP support?
Antworten
-
An advice could proxied a constructor’s class
-
A pointcut could select methods that have a custom annotation
-
Static initialization code could be targeted by a point cut
-
Combination of pointcuts by &&, || and the ! operators is not supported
Frage 28
Frage
Using the Spring AOP framework, what are the joinpoint methods of the following pointcut expressions?
execution(public * *(..))
Antworten
-
The execution of all public method
-
The execution of all public method returning a value
-
The execution of all public method having at least one parameter
-
The execution of all public method in class belonging to the default java package
Frage 29
Frage
Why is it a best practice to mark transaction as read-only when code does not write anything to the database? Select one or more answers.
Antworten
-
It is mandatory for using Spring exception translation mechanism
-
May be improve performance when using Hibernate
-
Spring optimizes its transaction interceptor
-
Provides safeguards with Oracle and some other databases
Frage 30
Frage
What data access technology is supported by the Spring framework? Select one or more answers.
Frage 31
Frage
What is not provided by the JdbcTemplate? Select a unique answer.
Frage 32
Frage
Using JdbcTemplate, what is the Spring provided class you will use for result set parsing and merging rows into a single object? Select a unique answer.
Antworten
-
RowMapper
-
RowCallbackHandler
-
ResultSetExtractor
-
ResultSetMapper
Frage 33
Frage
What configuration is supported by the LocalSessionFactoryBean which supports Hibernate 4 or higher? Select a unique answer.
Antworten
-
Listing entity classes annotated with @Entity
-
Scanning a package to detect annotated entity classes (with @Entity)
-
Listing hibernate XML mapping configuration file (.hbm.xml)
-
All above
Frage 34
Frage
What is/are incorrect statements about XML declaration of the transaction manager bean? Select one or more answers.
Antworten
-
The tx namespace provides JTA transaction manager declaration shortcut syntax
-
Id of the bean has to be transactionManager
-
Depending the application persistence technology, the HibernateTransactionManager or the DataSourceTransactionManager could be used as bean class
-
Default transaction timeout could be given
Frage 35
Frage
Assuming @Transactional annotation support is enabled and the transferMoney method is called through a Spring AOP proxy, what is the behavior of the following code sample?
@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}
Antworten
-
The add() method executes code in a new transaction
-
The add() method uses the transaction of the transferMoney() method
-
When calling the add() method, an exception is thrown
-
Other behavior
Frage 36
Frage
Does Spring provide programmatic transaction management? Select a unique answer.
Antworten
-
Yes with the TransactionTemplate class
-
Yes with the TransactionService class
-
Yes using the @Transactional bean post processor
-
No
Frage 37
Frage
What is the transaction behavior of the PROPAGATION_REQUIRES_NEW mode? Select a unique answer.
Antworten
-
If a transaction exists, the current method should run within this transaction. Otherwise, it should start a new transaction and run within its own transaction.
-
If a transaction is in progress, the current method should run within the nested transaction of the existing transaction. Otherwise, a new transaction has to be started and run within its own transaction.
-
The current method must start a new transaction and run within its own transaction. If there is an existing transaction in progress, it is suspended.
-
None of the above
Frage 38
Frage
What is the default rollback policy in transaction management?
Antworten
-
Rollback for any Exception
-
Rollback for RuntimeException
-
Rollback for checked exceptions
-
Always commit
Frage 39
Frage
What could not return a Spring MVC controller? Select a single answer.
Frage 40
Frage
Where do you cannot declare Spring MVC controller? Select one or more answers.
Antworten
-
In a Spring application context XML configuration file
-
Into the web.xml file of the web application
-
Into the java code by using annotations
-
Into the JSP pages
Frage 41
Frage
What is the easiest method to write a unit test?
Antworten
-
void displayAccount(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
-
void displayAccount(HttpServletRequest req, HttpSession Session)
throws ServletException, IOException
-
@RequestMapping("/displayAccount")
String displayAccount(@RequestParam("accountId") int id, Model model)
-
1. @RequestMapping("/displayAccount")
String displayAccount(@PathVariable("accountId") int id, Model model)
Frage 42
Frage
How could you secure MVC controller with Spring Security? Select a unique answer.
Antworten
-
With the @Secured annotation
-
With the @RolesAllowed annotation
-
In a XML security configuration file
-
All of the above
-
None of the above
Frage 43
Frage
What are the possible mechanisms provided by Spring Security to store user details? Select one or more correct answers.
Antworten
-
Database
-
JAAS
-
LDAP
-
Properties file
Frage 44
Frage
What is right about Spring Security configuration and the security namespace? Select one or more correct answers.
Antworten
-
The access attribute of the intercept-url tag support both EL and constants together.
-
The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is the first that matches.
-
The patterns declared into the intercept-url tag use by default the java regex syntax.
-
Security rules may apply depending request parameter
Frage 45
Frage
Which of the following is true regarding the below Spring controller?
@RestController
public class OwnerController {
@RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.POST)
@ResponseBody
public Owner findOwner(@PathVariable("ownerId") int ownerId) {
return new Owner();
}
}
Antworten
-
RequestMethod.GET method is more accurate than POST
-
@PathVariable should be replaced with the @PathParam annotation
-
Returning the 201 HTTP status code is better
-
@ResponseBody could be removed
Frage 46
Frage
Which of the following statements is true regarding the @ResponseStatus annotation?
Antworten
-
@ResponseStatus is detected on nested exceptions
-
The ExceptionHandlerExceptionResolver uses the @ResponseStatus annotation to map exception to HTTP status code
-
A controller handler is annotated with the @ResponseStatus, the response status set by RedirectView takes precedence over the annotation value.
-
The @ResponseStatus annotation can go on a @RequestMapping method or a @RestController class or a business exception class.
Frage 47
Frage
Compared to monolithic application, what are the advantage(s) of microservices?
Frage 48
Frage
What Spring Cloud provides in a microservices architecture?
Antworten
-
A Service Discovery implementation
-
A server for externalized configuration
-
A Dockerfile building an image that runs any Spring Boot application
-
Netflix OSS integration for Spring Boot
Frage 49
Frage
What provides Spring Boot?
Antworten
-
Support for Jetty and Undertow as embedded containers
-
Java code generation
-
Auto-configuration of the Spring Framework and third libraries
-
Convenient dependency descriptors to load transitive dependencies
-
Support both Java-based and YAML for Spring application context configuration
Frage 50
Frage
What is the name of the default environment configuration file of Spring Boot?
Antworten
-
application.json
-
configuration.spring
-
configuration.yml
-
configuration.xml
-
application.properties