Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Core Spring 5 - Test 9

Total questions: 50

Worksheet time: 2hrs 40mins

Name
Class
Date
1.
a)

Create - PATH

b)

Read - GET

c)

Update - POST/PUT

d)

Delete - DELETE

2.
a)

True

b)

False

3.
a)

True

b)

False

4.
a)

Only in com.whizlabs.component.scan

b)

In com.whizlabs.component.scan and com.whizlabs.component.scan.questions

c)

In com.whizlabs.component and com.whizlabs.component.scan

d)

In all of the packages for the application

5.
a)

True

b)

False

6.
a)

True

b)

False

7.
a)

.JSON

b)

.properties

c)

.yml/.yaml

d)

.xml

8.
a)

@Repository

b)

@Bean

c)

@Service

d)

@Controller

9.
a)

Methods annotated with @PreDestroy are called before the destroy() method of the interface DisposableBean.

b)

Methods annotated with @PreDestroy and @PostConstruct are always called, whatever the scope of the bean is.

c)

Methods annotated with @PostConstruct are called after afterPropertiesSet() method of the interface InitializingBean.

d)

Spring calls methods annotated with @PreDestroy and @PostConstruct only once.

10.
a)

Field injection using @Auwotowired annotation is achieved by using Java Refletion behind the scenes.

b)

Private fields cannot be injected using the @Autowired annotation.

c)

@Autowired uses the field name as a default qualifier.

d)

@Autowired can be used inside methods to provide dependencies for local variables.

11.
a)

A database driver

b)

spring-data-jpa.jar in your class path.

c)

Database credentials(usually username and password)

d)

URL connection

12.
a)

Adding @EnableGlobalMethodSecurity(securedEnabled = true) will enable method-level security.

b)

No additional annotation should be added, method-level security is enabled out of the box.

c)

Both @Secured and @PreAuthorize can use SpEL

d)

To enable @PreAuthorize, @PreFilter, @PostAuthorize and @PostFilter prePostEnabled attribute of the @EnableGlobalMethodSecurity element that must be configured to have the true value.

13.
a)

Model

b)

ServletResponse

c)

Errors

d)

ServletRequest

14.
a)

Read uncommitted

b)

Serializable

c)

Repeatable Reads

d)

Read commited

15.
a)

True

b)

False

16.
a)

Monitoring

b)

Metrics

c)

Live reloading of the code

d)

Health-checks

17.
a)

Pointcut

b)

Join point

c)

Advice

d)

Aspect

18.
a)

They can map a String(the logical name of the view) to a View

b)

An application can have only one implementation of ViewResolver

c)

An application can have more than one implementation of ViewResolver and we can control their priority

d)

Spring Framework provides a ViewResolver implementation and we are not obliged to register one.

19.
a)

AnnotationConfigApplicationContext

b)

ConfigurableWebApplicationContext

c)

WebApplicationContext

d)

AnnotationConfigWebApplicationContext

20.
a)

Exception and all of its subclasses

b)

RuntimeException and its subclasses

c)

Error and its subclasses

d)

All of the above

21.
a)

metrics

b)

loggers

c)

health

d)

info

22.
a)

4xx

b)

5xx

c)

3xx

d)

2xx

23.
a)

Final methods can be advised.

b)

Self-invation is not supported.

c)

A subclass is generated for each proxied object.

d)

CGLIB Proxy will intercept private method calls.

24.
a)

management.endpoints.web.exposure.include=beans

b)

management.endpoints.web.exposure.include.beans=true

c)

management.endpoints.web.exposure.include=*

d)

management.endpoints.web.exposure.exclude.beans=false

25.
a)

Authentication

b)

Credentials

c)

Authorization

d)

Principal

26.
a)

Every project must have a spring.factories file

b)

If present, spring.factories is located in META-INF folder

c)

spring.factories can be replaced with application.properties

d)

spring.factories contains a list of auto-configuration class candidates

27.
a)

http://localhost:8080/city?name=Bangalore will map to the method cityMethod.

b)

http://localhost:8080/city will map to the method cityMethod.

c)

http://localhost:8080/city?cityName=Bangalore will map to the method cityMethod.

d)

We can replace @ReqestParam(required=false) String city with @ReqestParam Optional<String> city without changing the logic

28.
a)

Unit test

b)

Assertion

c)

Integration test

d)

System test

29.
a)

BeanFactoryPostProcessor is invoked after all the Spring Beans are created

b)

BeanFactoryPostProcessor has a single method called postProcess

c)

BeanFactoryPostProcessor does not create beans but it can access and alter the Metadata that is used to create beans

d)

BeanFactoryPostProcessor is a Spring bean as well.

30.
a)

@Component

b)

@Controller

c)

@Autowired

d)

@Service

31.
a)

Apache Tomcat

b)

Apache Geronimo

c)

Jetty

d)

Undertow

32.
a)

True

b)

False

33.
a)

True

b)

False

34.
a)

@Transactional can be placed on top of getByIdPositive instead of RepositoryTests and the class logic will be the same

b)

Both getByIdNegative and getByIdPositive will be executed in a transaction.

c)

Transactions for all the tests which are executed in the RepositoryTests class will be rolled-back

d)

We can add @Commit on top of RepositoryTests class to commit the transaction after each test execution

35.
a)

@Bean

b)

@Autowired

c)

@Inject

d)

@Resource

36.
a)

@Configuration

b)

@ComponentScan

c)

@ContextConfiguration

d)

@EnableAutoConfiguration

37.
a)

It must be the first parameter of an advice.

b)

It is supported by all of the advice types in Spring AOP.

c)

It can be used to retrieve the arguments of the join point(method arguments)

d)

We can have only one Joinpoint argument.

38.
a)

application.properties

b)

application.json

c)

application.yaml

d)

application.xml

39.
a)

@Mock

b)

@MockBean

c)

@Inject

d)

@InjectMocks

40.
a)

Create an interface which extends any of Repository,CrudRepository,JpaRepository or PagingAndSortingRepository.

b)

Create an interface which extends any of Repository,CrudRepository,JpaRepository or PagingAndSortingRepository.

c)

Use @EnableJpaRepositories on top of your configuration class and point out the package to search for repositories.

d)

Create a class annotated with @Entity that will be used by the repository.

41.
a)

A class can have any number of methods annotated with @PostConstruct.

b)

A method that is anoteted with @PostConstruct must be private.

c)

A method that is annotated with @PostConstruct must be final.

d)

Method annotated with @PostConstruct is called after dependency injection is done.

42.
a)

Application context holds all of the bean definitions within your application.

b)

ApplicationContext is an abstract class that implements the interface BeanFactory.

c)

Application context manages beans lifecycle.

d)

All of the above.

43.
a)

In configuration files - application.properties/.yaml

b)

Through command line arguments using --debug argument when launching the application

c)

Through Environment variables

d)

Using logging specific configuration, for example logback-spring.xml

44.
a)

True

b)

False

45.
a)

True

b)

False

46.
a)

Read commited

b)

Read uncommited

c)

Repateable Reads

d)

Serializable

47.
a)

Around advice(@Around)

b)

After throwing advice(@AfterThrowing)

c)

Before advice(@Before)

d)

After (finally) advice(@After)

48.
a)

@WebMvcTest is a class level annotation

b)

You can specify a single controller for @WebMvcTest to auto-configure

c)

@WebMvcTest will create ApplicationContext that contains only web components

d)

When using @WebMvcTest with JUnit 5 @ExtendWith(SpringExtension.class) must be used in order for the test class to work correctly

49.
a)

It scans and configures @Entity beans

b)

It scans and configures Spring Data Repositories

c)

It scans and configures @Service annotated classes

d)

It configures in-memory embedded database

50.
a)

RowMapper

b)

PreparedStatementCreator

c)

ResultSetExtractor

d)

RowCallbackHandler