Font size
WorksheetsCore Spring 5 Test 6
Total questions: 49
Worksheet time: 2hrs 27mins
Which of these advices, when used, will have a chance to execute some code after the join point execution throws an exception? select all that apply.
@AfterThrowing
@AfterReturning
@Around
@After
In spring mvc, which of these can be the return type of a method annotated with @requestmapping? select all that apply.
ModelAndView
void
String
Model
Fill in the blanks. select the one that applies best. rpc mechanisms like soap web services are centered on ______. ______ is a popular alternative, and is centered on ______.
actions and processes, JMS, information and resources
information and resources, REST, actions and processes
actions and processes, REST, information and resources
information and resources, JMS, actions and processes
@springbootapplication is equivalent to which annotation? select one
A & C
@Configuration, @ComponentScan, @EnableAutoConfiguration
@EnableJpaReposorities, @ComponentScan, @EnableAutoConfiguration, @Configuration
@SpringBootConfiguration, @ComponentScan, @EnableAutoConfiguration
Which of these is true about @bean methods that are marked with a java 'static' modifier? select all that apply.
it avoids triggering other parts of the configuration at that point of definition.
it is necessary when beans will get initialized early in the container lifecycle.
the 'static' modifier allows a method to be called without creating its containing configuration class as an instance.
They will never get intercepted by the container, not even within @Configuration classes.
Which of these is the one being described below? select the one that applies best.
it makes invoking many restful services simpler while enforcing rest best practices.
HttpMessageProducer
RestTemplate
RestMessageProducer
HttpTemplate
Which of these maps incoming web requests to appropriate handlers?
ViewResolver
HandlerMapping
RequestHandler
FlashMapManager
Spring Boot
Spring IO
Spring Bootstrap
Spring Configuration
Which of these are true about aop proxies? select all that apply.
In Spring AOP, if the target object implements an interface, it defaults to using the standard JDK dynamic proxies, and can never be overridden to force the use CGLIB instead.
Spring AOP proxies are woven in at compile time
Spring AOP is proxy-based
Spring AOP can use either CGLIB or JDK dynamic proxies on target that does not implement any interface.
JDBCTransactionManager
DataSourceTransactionManager
JDBCDataSourceTransactionManager
JDBCPlatformTransactionManager
Which of these is true regarding spring aop proxies?
Spring AOP cannot use CGLIB proxies if the target method is final (marked with 'final' modifier of java).
Spring AOP cannot use CGLIB proxies if the target object implements an interface.
Spring AOP cannot use JDK dynamic proxies if the target object does not implement an interface.
A and B.
Which of these can be used by spring boot to externalize configuration? select all that apply.
properties files
YAML files
XML files
environment variables
How can you disable some autoconfiguration classes, if they don't suit your needs?
A&D
@EnableAutoConfiguration(provided= DataSourceAutoConfiguration.class)
@ExcludeAutoConfiguration(exclude= DataSourceAutoConfiguration.class)
@EnableAutoConfiguration(exclude= DataSourceAutoConfiguration.class)
public Order getOrder(@pathVariable("id")long id){....}
public Order getOrder(@pathVariable("orderId")long orderId{...} c. public Order getOrder(@pathVariable("id")String id){....}
B & C
In spring mvc, which of these are true regarding the @requestparam annotation? select all that apply.
The 'mandatory' attribute can be specified inside the @RequestParam, to specify if a parameter is required or not.
Given that 'enter' is annotated with @RequestMapping, below is valid: public String enter(@RequestParam("carId") int carId, ModelMap m) {
The @RequestParam annotation binds request parameters to handler method parameters.
Parameters using this annotation are not required by default.
Which of these can be used when spring data repositories are implemented at runtime?
Byte-code generation
JDK proxy
CGLIB
All of the above
It is described as a stage during the execution of a program, such as the execution of a method or the handling of an exception. in spring aop, it always represents a method execution. select the one that applies best.
Join point
Pointcut
Aspect
Advice
On which of these can you annotate the @profile? select all that apply.
Method
Method parameter
Class
Return Type
Which of these can be used in loading a root application context in a web application? select all that apply.
BeanFactoryPostProcessor
DispatcherServlet
WebApplicationContext
ContextLoaderListener
Which statements are true regarding aop advices? select all that apply.
The proceed() on the ProceedingJoinPoint, in an @Around advice method, must be called up to 1 time only.
Using @AfterThrowing with its property 'throwing', further filters the pointcut matching into those methods that throw the exception type associated with the 'throwing' property.
The first parameter of the @Around advice method must be of type ProceedingJoinPoint.
@AfterFinally advise is executed whether the advised method exits normally or not (throws exception).
Which of these are true regarding spring security? select all that apply
@RolesAllowed can be used to implement method-level security.
Spring Security user details cannot be stored in LDAP
Spring Security can work with encoded passwords using the '<encode-password>' element.
The 'authorize' tag can be used in a JSP.
BeanNameViewResolver
JSPBasedViewResolver
InternalResourceviewResolver
UrlBasedViewResolver
During which phase can beanpostprocessor modify the bean initialization?
AfterInit
Postconstruct
A&B
BeforeInit
method
requires-channel
filters
access
isolation level
transaction propagation
transaction manager
transaction proxy
Which of these advice types can be defined using annotations? select all that apply.
After throwing advice
After returning (with no exception) advice
Before advice
Around advice
Which of these is the order of the database system isolation levels, from lowest to the highest?
Read uncommitted, Read committed, Repeatable reads, Serializable
Read uncommitted, Repeatable reads, Serializable, Read committed
Read committed, Repeatable reads, Serializable, Read uncommitted
Repeatable reads, Read uncommitted, Read committed, Serializable
Which of these can be used in java-based or annotation-based spring configuration? select all that apply.
@Import
@Autowired
@PreDestroy
@Required
@RequestMapping
@RequestMethod
@PathVariable
@RequestBody
A bean annotated with 'session' scope is created:
Each time the bean is referenced.
Once per user session.
Once per request.
All of the above.
Can you load the separate applicationcontext for junit test? select one
Yes @ApplicationContext(ClassName.class)
No, it is not possible
Yes @ContextConfiguration(className.class)
A & c
Which of these is true about @entity?
When annotated on a method, @Entity makes the return value of the method be persisted into the database.
@Entity can be annotated on methods and classes.
@Entity is part of JPA.
All of the above
What is the best practices?
@ComponentScan ({com.bank.app})
@ComponentScan ({"com.bank.app.repositorty", "com.bank.app.service", "com.bank.app.controller"})
@ComponentScan("com")
@componentScan({"org","com"})
Which of these design patterns is spring's jdbctemplate based on?
state
template
command
strategy
Which of the statements is true?
- Spring beans are managed by the Spring IoC container.
- Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.
- Spring beans are simple POJOs.
All of the above
BeanPostProcessor
BeanFactoryPostProcessor
PropertyPlaceholderConfigurer
BeanPreProcessor
model
theme
request parameters
locale
Which of these statements are true regarding spring's support for javax.sql.datasource? select all that apply
Spring's DriverManagerDataSource provides pooling.
Spring's DriverManagerDataSource performs well in a multiple-request production environment.
Spring obtains a connection to the database through a DataSource.
Spring's SingleConnectionDataSource is multi-threading capable.
Which of these are true about @query in spring data? select all that apply.
Named queries declared in orm.xml will take precedence over queries annotated to the query method using @Query.
The execution of pagination or dynamic sorting for native queries is not supported.
The @Query annotation allows to execute native queries by setting the 'native' flag to true.
Queries defined using @NamedQuery will take precedence over queries annotated to the query method using @Query.
Which of these are considered idempotent rest operations? select all that apply
POST
PUT
DELETE
GET
Which of these are http methods which are supported by resttemplate? select all that apply.
DELETE
PUT
OPTIONS
HEAD
Which of these statements are true regarding the dataaccessexception exception class hierarchy? select all that apply.
The DataAccessException class is in the java.lang package.
DataAccessException instances thrown , wrap the original exception
Its use allows one to switch between persistence technologies fairly easily and it also allows one to code without worrying about catching exceptions that are specific to each technology.
Its use helps convert proprietary checked exceptions, to a set of runtime exceptions.
@ResponseStatus, 500
@HttpResponseStatus, 404
@HttpResponseStatus, 500
@ResponseStatus, 404
Repeatable reads
Serializable
Read committed
Read uncommitted
exception will be thrown
jpaAccountRepository
Once per request
jdbcAccountRepository
The MyRepoImpl will be created as a Spring bean, when the "uat" profile is active.
@Profile can be annotated on methods.
It is an invalid usage of the @Profile annotation.
The MyRepoImpl will be created as a Spring bean, when the "dev" profile is active.
What is an aspect?
Technique by which aspect are combined with main code.
A module that encapsulate pointcuts and advice
An expression that selects on or more join point
Code to be executed at each selected join poin
The use of this makes it easier to mock and/or test java classes. select the one that applies best.
Spring AOP
template design pattern
Spring Expression Language (SpEL)
java interfaces
Which one is true about scopes?
By default, a 'singleton' is initialized only when a client requests it, and stored in a cache for all subsequent requests to use.
Configured destruction lifecycle callbacks on prototypes are not called.
Ideally, use the prototype scope for all stateless beans and the singleton scope for stateful beans.
All of the above
