Pregunta 1
Pregunta
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"/>
Respuesta
-
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
Pregunta 2
Pregunta
Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>
Respuesta
-
The p namespace has to be declared
-
Bean id is bankServiceImpl
-
The BankServiceImpl references a NationalBank bean
-
NationalBank is a scalar value
Pregunta 3
Pregunta
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;
}
}
Pregunta 4
Pregunta
How could you externalize constants from a Spring configuration file or a Spring annotation into a .properties file? Select one or more answers
Respuesta
-
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
Pregunta 5
Pregunta
What statement is not correct in live environment? Select a unique answer.
Respuesta
-
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
Pregunta 6
Pregunta
What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy annotations?
Respuesta
-
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
Pregunta 7
Pregunta
What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?
Pregunta 8
Pregunta
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");
Respuesta
-
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
Pregunta 9
Pregunta
How to auto-inject into a field a Spring bean by its name? Select one or more answer choices.
Respuesta
-
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
Pregunta 10
Pregunta
What are the main advantages of using interfaces when designing business services? Select one or more answer choices.
Respuesta
-
Mocking or stubbing the service
-
Be able to use the Spring auto-injection
-
Can do dependency checking
-
Loosely coupled code
Pregunta 11
Pregunta
Select one or many correct answers about Spring bean life cycle.
Respuesta
-
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
Pregunta 12
Pregunta
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();
}
}
Pregunta 13
Pregunta
What are the features of the XML <context:namespace? Select one or many answers.
Respuesta
-
@Transactional annotation scanning
-
@Aspect annotation detection enabling
-
@Autowired annotation enabling
-
@Component annotation scanning
Pregunta 14
Pregunta
Select one or more correct statements about developing integration test with Spring support.
Respuesta
-
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
Pregunta 15
Pregunta
What are the main advantage(s) for using Spring when writing integration tests?
Pregunta 16
Pregunta
What are the main advantage(s) for using Spring when writing unit tests?
Pregunta 17
Pregunta
What is right about the Spring test module?
Respuesta
-
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
Pregunta 18
Pregunta
Select correct statement(s) about transactional support of the Spring test module.
Respuesta
-
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
Pregunta 19
Pregunta
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(..))
Respuesta
-
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
Pregunta 20
Pregunta
Using the Spring AOP framework, what is the visibility of the method matches by the following join point?
@Pointcut("execution(* *(..))")
private void anyOperation() {};
Respuesta
-
All methods, whereas their visibility
-
All methods, except private method
-
Protected and public methods
-
Public methods
Pregunta 21
Pregunta
What are the 2 correct statements about AOP proxy?
Respuesta
-
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
Pregunta 22
Pregunta
What is an after throwing advice? Select a unique answer.
Respuesta
-
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
Pregunta 23
Pregunta
What is an after returning advice? Select a unique answer.
Respuesta
-
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
Pregunta 24
Pregunta
What is an advice? Select a unique answer.
Respuesta
-
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
Pregunta 25
Pregunta
What is a pointcut? Select the single answer.
Respuesta
-
Code to execute at a join point
-
An expression to identify joinpoints
-
An advice and a jointpoint
-
None of the above
Pregunta 26
Pregunta
Select method’s signatures that match with the following pointcut:
execution(* com.test.service..*.*(*))
Respuesta
-
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
Pregunta 27
Pregunta
What are the unique right answer about Spring AOP support?
Respuesta
-
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
Pregunta 28
Pregunta
Using the Spring AOP framework, what are the joinpoint methods of the following pointcut expressions?
execution(public * *(..))
Respuesta
-
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
Pregunta 29
Pregunta
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.
Respuesta
-
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
Pregunta 30
Pregunta
What data access technology is supported by the Spring framework? Select one or more answers.
Pregunta 31
Pregunta
What is not provided by the JdbcTemplate? Select a unique answer.
Pregunta 32
Pregunta
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.
Respuesta
-
RowMapper
-
RowCallbackHandler
-
ResultSetExtractor
-
ResultSetMapper
Pregunta 33
Pregunta
What configuration is supported by the LocalSessionFactoryBean which supports Hibernate 4 or higher? Select a unique answer.
Respuesta
-
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
Pregunta 34
Pregunta
What is/are incorrect statements about XML declaration of the transaction manager bean? Select one or more answers.
Respuesta
-
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
Pregunta 35
Pregunta
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
}
Respuesta
-
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
Pregunta 36
Pregunta
Does Spring provide programmatic transaction management? Select a unique answer.
Respuesta
-
Yes with the TransactionTemplate class
-
Yes with the TransactionService class
-
Yes using the @Transactional bean post processor
-
No
Pregunta 37
Pregunta
What is the transaction behavior of the PROPAGATION_REQUIRES_NEW mode? Select a unique answer.
Respuesta
-
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
Pregunta 38
Pregunta
What is the default rollback policy in transaction management?
Respuesta
-
Rollback for any Exception
-
Rollback for RuntimeException
-
Rollback for checked exceptions
-
Always commit
Pregunta 39
Pregunta
What could not return a Spring MVC controller? Select a single answer.
Pregunta 40
Pregunta
Where do you cannot declare Spring MVC controller? Select one or more answers.
Respuesta
-
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
Pregunta 41
Pregunta
What is the easiest method to write a unit test?
Respuesta
-
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)
Pregunta 42
Pregunta
How could you secure MVC controller with Spring Security? Select a unique answer.
Respuesta
-
With the @Secured annotation
-
With the @RolesAllowed annotation
-
In a XML security configuration file
-
All of the above
-
None of the above
Pregunta 43
Pregunta
What are the possible mechanisms provided by Spring Security to store user details? Select one or more correct answers.
Respuesta
-
Database
-
JAAS
-
LDAP
-
Properties file
Pregunta 44
Pregunta
What is right about Spring Security configuration and the security namespace? Select one or more correct answers.
Respuesta
-
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
Pregunta 45
Pregunta
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();
}
}
Respuesta
-
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
Pregunta 46
Pregunta
Which of the following statements is true regarding the @ResponseStatus annotation?
Respuesta
-
@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.
Pregunta 47
Pregunta
Compared to monolithic application, what are the advantage(s) of microservices?
Pregunta 48
Pregunta
What Spring Cloud provides in a microservices architecture?
Respuesta
-
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
Pregunta 49
Pregunta
What provides Spring Boot?
Respuesta
-
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
Pregunta 50
Pregunta
What is the name of the default environment configuration file of Spring Boot?
Respuesta
-
application.json
-
configuration.spring
-
configuration.yml
-
configuration.xml
-
application.properties