wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Core Spring 5 Test 6

Total questions: 49

Worksheet time: 2hrs 27mins

Name
Class
Date
1.

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.

a)

@AfterThrowing

b)

@AfterReturning

c)

@Around

d)

@After

2.

In spring mvc, which of these can be the return type of a method annotated with @requestmapping? select all that apply.

a)

ModelAndView

b)

void

c)

String

d)

Model

3.

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

a)

actions and processes, JMS, information and resources

b)

information and resources, REST, actions and processes

c)

actions and processes, REST, information and resources

d)

information and resources, JMS, actions and processes

4.

@springbootapplication is equivalent to which annotation? select one

a)

A & C

b)

@Configuration, @ComponentScan, @EnableAutoConfiguration

c)

@EnableJpaReposorities, @ComponentScan, @EnableAutoConfiguration, @Configuration

d)

@SpringBootConfiguration, @ComponentScan, @EnableAutoConfiguration

5.

Which of these is true about @bean methods that are marked with a java 'static' modifier? select all that apply.

a)

it avoids triggering other parts of the configuration at that point of definition.

b)

it is necessary when beans will get initialized early in the container lifecycle.

c)

the 'static' modifier allows a method to be called without creating its containing configuration class as an instance.

d)

They will never get intercepted by the container, not even within @Configuration classes.

6.

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.

a)

HttpMessageProducer

b)

RestTemplate

c)

RestMessageProducer

d)

HttpTemplate

7.

Which of these maps incoming web requests to appropriate handlers?

a)

ViewResolver

b)

HandlerMapping

c)

RequestHandler

d)

FlashMapManager

8.
a)

Spring Boot

b)

Spring IO

c)

Spring Bootstrap

d)

Spring Configuration

9.

Which of these are true about aop proxies? select all that apply.

a)

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.

b)

Spring AOP proxies are woven in at compile time

c)

Spring AOP is proxy-based

d)

Spring AOP can use either CGLIB or JDK dynamic proxies on target that does not implement any interface.

10.
a)

JDBCTransactionManager

b)

DataSourceTransactionManager

c)

JDBCDataSourceTransactionManager

d)

JDBCPlatformTransactionManager

11.

Which of these is true regarding spring aop proxies?

a)

Spring AOP cannot use CGLIB proxies if the target method is final (marked with 'final' modifier of java).

b)

Spring AOP cannot use CGLIB proxies if the target object implements an interface.

c)

Spring AOP cannot use JDK dynamic proxies if the target object does not implement an interface.

d)

A and B.

12.

Which of these can be used by spring boot to externalize configuration? select all that apply.

a)

properties files

b)

YAML files

c)

XML files

d)

environment variables

13.

How can you disable some autoconfiguration classes, if they don't suit your needs?

a)

A&D

b)

@EnableAutoConfiguration(provided= DataSourceAutoConfiguration.class)

c)

@ExcludeAutoConfiguration(exclude= DataSourceAutoConfiguration.class)

d)

@EnableAutoConfiguration(exclude= DataSourceAutoConfiguration.class)

14.
a)

public Order getOrder(@pathVariable("id")long id){....}

b)

public Order getOrder(@pathVariable("orderId")long orderId{...} c. public Order getOrder(@pathVariable("id")String id){....}

c)

B & C

15.

In spring mvc, which of these are true regarding the @requestparam annotation? select all that apply.

a)

The 'mandatory' attribute can be specified inside the @RequestParam, to specify if a parameter is required or not.

b)

Given that 'enter' is annotated with @RequestMapping, below is valid: public String enter(@RequestParam("carId") int carId, ModelMap m) {

c)

The @RequestParam annotation binds request parameters to handler method parameters.

d)

Parameters using this annotation are not required by default.

16.

Which of these can be used when spring data repositories are implemented at runtime?

a)

Byte-code generation

b)

JDK proxy

c)

CGLIB

d)

All of the above

17.

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.

a)

Join point

b)

Pointcut

c)

Aspect

d)

Advice

18.

On which of these can you annotate the @profile? select all that apply.

a)

Method

b)

Method parameter

c)

Class

d)

Return Type

19.

Which of these can be used in loading a root application context in a web application? select all that apply.

a)

BeanFactoryPostProcessor

b)

DispatcherServlet

c)

WebApplicationContext

d)

ContextLoaderListener

20.

Which statements are true regarding aop advices? select all that apply.

a)

The proceed() on the ProceedingJoinPoint, in an @Around advice method, must be called up to 1 time only.

b)

Using @AfterThrowing with its property 'throwing', further filters the pointcut matching into those methods that throw the exception type associated with the 'throwing' property.

c)

The first parameter of the @Around advice method must be of type ProceedingJoinPoint.

d)

@AfterFinally advise is executed whether the advised method exits normally or not (throws exception).

21.

Which of these are true regarding spring security? select all that apply

a)

@RolesAllowed can be used to implement method-level security.

b)

Spring Security user details cannot be stored in LDAP

c)

Spring Security can work with encoded passwords using the '<encode-password>' element.

d)

The 'authorize' tag can be used in a JSP.

22.
a)

BeanNameViewResolver

b)

JSPBasedViewResolver

c)

InternalResourceviewResolver

d)

UrlBasedViewResolver

23.

During which phase can beanpostprocessor modify the bean initialization?

a)

AfterInit

b)

Postconstruct

c)

A&B

d)

BeforeInit

24.
a)

method

b)

requires-channel

c)

filters

d)

access

25.
a)

isolation level

b)

transaction propagation

c)

transaction manager

d)

transaction proxy

26.

Which of these advice types can be defined using annotations? select all that apply.

a)

After throwing advice

b)

After returning (with no exception) advice

c)

Before advice

d)

Around advice

27.

Which of these is the order of the database system isolation levels, from lowest to the highest?

a)

Read uncommitted, Read committed, Repeatable reads, Serializable

b)

Read uncommitted, Repeatable reads, Serializable, Read committed

c)

Read committed, Repeatable reads, Serializable, Read uncommitted

d)

Repeatable reads, Read uncommitted, Read committed, Serializable

28.

Which of these can be used in java-based or annotation-based spring configuration? select all that apply.

a)

@Import

b)

@Autowired

c)

@PreDestroy

d)

@Required

29.
a)

@RequestMapping

b)

@RequestMethod

c)

@PathVariable

d)

@RequestBody

30.

A bean annotated with 'session' scope is created:

a)

Each time the bean is referenced.

b)

Once per user session.

c)

Once per request.

d)

All of the above.

31.

Can you load the separate applicationcontext for junit test? select one

a)

Yes @ApplicationContext(ClassName.class)

b)

No, it is not possible

c)

Yes @ContextConfiguration(className.class)

d)

A & c

32.

Which of these is true about @entity?

a)

When annotated on a method, @Entity makes the return value of the method be persisted into the database.

b)

@Entity can be annotated on methods and classes.

c)

@Entity is part of JPA.

d)

All of the above

33.

What is the best practices?

a)

@ComponentScan ({com.bank.app})

b)

@ComponentScan ({"com.bank.app.repositorty", "com.bank.app.service", "com.bank.app.controller"})

c)

@ComponentScan("com")

d)

@componentScan({"org","com"})

34.

Which of these design patterns is spring's jdbctemplate based on?

a)

state

b)

template

c)

command

d)

strategy

35.

Which of the statements is true?

a)

- Spring beans are managed by the Spring IoC container.

b)

- Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.

c)

- Spring beans are simple POJOs.

d)

All of the above

36.
a)

BeanPostProcessor

b)

BeanFactoryPostProcessor

c)

PropertyPlaceholderConfigurer

d)

BeanPreProcessor

37.
a)

model

b)

theme

c)

request parameters

d)

locale

38.

Which of these statements are true regarding spring's support for javax.sql.datasource? select all that apply

a)

Spring's DriverManagerDataSource provides pooling.

b)

Spring's DriverManagerDataSource performs well in a multiple-request production environment.

c)

Spring obtains a connection to the database through a DataSource.

d)

Spring's SingleConnectionDataSource is multi-threading capable.

39.

Which of these are true about @query in spring data? select all that apply.

a)

Named queries declared in orm.xml will take precedence over queries annotated to the query method using @Query.

b)

The execution of pagination or dynamic sorting for native queries is not supported.

c)

The @Query annotation allows to execute native queries by setting the 'native' flag to true.

d)

Queries defined using @NamedQuery will take precedence over queries annotated to the query method using @Query.

40.

Which of these are considered idempotent rest operations? select all that apply

a)

POST

b)

PUT

c)

DELETE

d)

GET

41.

Which of these are http methods which are supported by resttemplate? select all that apply.

a)

DELETE

b)

PUT

c)

OPTIONS

d)

HEAD

42.

Which of these statements are true regarding the dataaccessexception exception class hierarchy? select all that apply.

a)

The DataAccessException class is in the java.lang package.

b)

DataAccessException instances thrown , wrap the original exception

c)

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.

d)

Its use helps convert proprietary checked exceptions, to a set of runtime exceptions.

43.
a)

@ResponseStatus, 500

b)

@HttpResponseStatus, 404

c)

@HttpResponseStatus, 500

d)

@ResponseStatus, 404

44.
a)

Repeatable reads

b)

Serializable

c)

Read committed

d)

Read uncommitted

45.
a)

exception will be thrown

b)

jpaAccountRepository

c)

Once per request

d)

jdbcAccountRepository

46.
a)

The MyRepoImpl will be created as a Spring bean, when the "uat" profile is active.

b)

@Profile can be annotated on methods.

c)

It is an invalid usage of the @Profile annotation.

d)

The MyRepoImpl will be created as a Spring bean, when the "dev" profile is active.

47.

What is an aspect?

a)

Technique by which aspect are combined with main code.

b)

A module that encapsulate pointcuts and advice

c)

An expression that selects on or more join point

d)

Code to be executed at each selected join poin

48.

The use of this makes it easier to mock and/or test java classes. select the one that applies best.

a)

Spring AOP

b)

template design pattern

c)

Spring Expression Language (SpEL)

d)

java interfaces

49.

Which one is true about scopes?

a)

By default, a 'singleton' is initialized only when a client requests it, and stored in a cache for all subsequent requests to use.

b)

Configured destruction lifecycle callbacks on prototypes are not called.

c)

Ideally, use the prototype scope for all stateless beans and the singleton scope for stateful beans.

d)

All of the above