wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Core Spring Test 7

Total questions: 50

Worksheet time: 2hrs 39mins

Name
Class
Date
1.
a)

endpoint.shutdown.enable=true

b)

management.endpoint.shutdown.enabled=true

c)

management.endpoint.enabled.shutdown=true

d)

endpoint.shutdown.disabled=false

2.
a)

True

b)

False

3.
a)

@SpringBootApplication

b)

@ContextConfiguration

c)

@EnableAutoConfiguration

d)

@ComponentScan

4.
a)

It can be used on classes annotated with @Controller.

b)

@RequestMapping will only map to GET requests unless explicitly specified different.

c)

It have attribute "method" which can be used to customize requests methods that this method will map to.

d)

We can specify the request parameters for the method using the attribute "requestParams".

5.
a)

It contains @ExtendWith(SpringExtension.class)

b)

It contains @RunWith(SpringRunner.class)

c)

It enables Spring Boot specific features on top of Spring Test

d)

It's used on test methods

6.
a)

Serializable

b)

Read commited

c)

Read uncommited

d)

Repeatable Reads

7.
a)

@WebMvcTest

b)

@TestConfiguration

c)

@JsonTest

d)

@DataJpaTest

8.
a)

Query

b)

Prepared statement

c)

Transaction

d)

Callback

9.
a)

Spring will use a class named SimpleJpaRepository by default to create beans for every Spring data repository.

b)

If not specified @EnableJpaRepositories will scan the package of the configuration class and any of its subpackages.

c)

To enable the usage of Spring data repositories the usse @EnableJpaRepositories on top of your configuration class is required.

d)

The class used for beans creation of Spring data repositories can be specified using repositoryBaseClass attribute of @EnableJpaRepositories.

10.
a)

home

b)

country

c)

city

d)

steet

11.
a)

HTTP

b)

SMTP

c)

FTP

d)

JMX

12.
a)

This method will return Map with key-value pairs for the row updated.

b)

This method returns void

c)

This method will update the first_name column of user with id=1 to John

d)

This method will return the id of the updated row

13.
a)

"execution (protected void com.whizlabs.spring.questions.aop.SomeClass.*)"

b)

"within (com..* throws Exception")

c)

"args(String)"

d)

"execution (void com..SomeClass.get*())"

14.
a)

@Configuration(enableAspectJAutoProxy=true)

b)

@AspectJConfiguration

c)

@EnableAspectJAutoProxy

d)

@Aspect

15.
a)

Spring Boot loads schema.sql for DDL and data.sql for DML from the classpath

b)

Spring Boot will start the application even if the loaded scripts fail

c)

Spring Boot will automatically initialize embedded and standalone databases

d)

Spring Boot will load the schema-${platform}.sql and data-${platform}.sql files (if present), where platform is the value of spring.datasource.platform

16.
a)

@PreAuthorize

b)

@PreFilter

c)

@RolesAllowed

d)

@PostAuthorize

17.
a)

GET

b)

PATCH

c)

PUT

d)

DELETE

18.
a)

getCities

b)

getCities2

c)

getCities3

d)

All of the above

19.
a)

@RequestMapping("/person") public String getPersonWithId1(@PathVariable("id") Long personId){ .... }

b)

@RequestMapping("/person") public String getPersonWithId2(@PathVariable Long personId){ .... }

c)

@RequestMapping("/person") public String getPersonWithId3(@RequestParam Long personId){ .... }

d)

@RequestMapping("/person") public String getPersonWithId4(@RequestParam("id") Long personId){ .... }

20.
a)

Use the registerShutdownHook method on the application context to register a shutdown hook.

b)

Use destroy() method declared in the class AbstractApplicationContext.

c)

Use the close() method declared in the interface AbstractApplicationContext.

d)

All of the above

21.
a)

Classes annotated with @Configuration can be final

b)

Methods annotated with @Bean can't be final

c)

Methods annotated with @Bean can be static

d)

Methods annotated with @Bean can be private

22.
a)

Spring Security can be configured via web.xml or via Java Configuration.

b)

The @EnableSpringSecurity annotation should be used on a @Configuration class to enable Spring Security

c)

@Secured annotation can be used on class level

d)

Spring Security is implemented only on web level

23.
a)

Request

b)

Response

c)

WebSocket

d)

Factory

24.
a)

@ConditionalOnClass

b)

@ConditionalOnBean

c)

@ConditionalOnMissingClass

d)

@ConditionalOnMissingBean

25.
a)

True

b)

False

26.
a)

PUT

b)

GET

c)

PATCH

d)

DELETE

27.
a)

DataSource is an interace from the Spring framework

b)

DataSource represents any data source for SQL database

c)

The DataSource interface is implemented by a driver vendor

d)

All of the above.

28.
a)

TransactionManager

b)

TransactionInterceptor

c)

TransactionTemplate

d)

PlatformTransactionManager

29.
a)

@Value("#{systemProperties['someProperty']}")

b)

@Value("$(systemProperties['someProperty'])")

c)

@Value("${someProperty}")

d)

@Value("#(someProperty)")

30.
a)

The @Autowired annotation will not work in Spring application with XML configuration.

b)

The @Autowired annotation can be used to inject a String value.

c)

For the @Autowired annotation to work a component scanning must be enabled.

d)

@Autowired has an attributed "required" and by default its value is false.

31.
a)

DataSource is always auto-configured in Spring Boot

b)

For DataSource to be autoconfigured and a bean to be created successfully, database connector must included as a dependency

c)

For DataSource to be autoconfigured and a bean to be created successfully, spring-boot-starter-data-jdbc must included as a dependency

d)

To auto configure DataSource it must be listed in the spring.factories file of your project

32.
a)

Read commited

b)

Repateable Reads

c)

Serializable

d)

Read uncommited

33.
a)

@Before

b)

@BeforeEach

c)

@BeforeAll

d)

@BeforeClass

34.
a)

True

b)

False

35.
a)

Around advice(@Around)

b)

After throwing advice(@AfterThrowing)

c)

After returning advice(@AfterReturning)

d)

After (finally) advice(@After)

36.
a)

SecurityContextHolder

b)

SecurityContext

c)

Authentication

d)

ProviderManager

37.
a)

Change the annotation from @Bean to @Bean("playerBeanId")

b)

Change the annotation from @Bean to @Bean(name="playerBeanId")

c)

Add @Qualifier("playerBeanId") on top of playerBean method

d)

Change the annotation from @Bean to @Bean(id="playerBeanId")

38.
a)

True

b)

False

39.
a)

@Component("specialPlayer")

b)

@Qualifier("specialPlayer")

c)

@Component(id="specialPlayer")

d)

@Bean(name="specialPlayer")

40.
a)

@PropertySource({"classpath:/myFile.properties","classpath:/myFile2.properties"})

b)

@PropertySource("classpath:/myFile.properties,classpath:/myFile2.properties")

c)

@PropertySources({ @PropertySource("classpath:/myFile.properties"), @PropertySource("classpath:/myFile2.properties") })

d)

@PropertySources( @PropertySource("classpath:/myFile.properties"), @PropertySource("classpath:/myFile2.properties") )

41.
a)

True

b)

False

42.
a)

"execution (void com..* throws java.io.IOException)"

b)

"args(..)"

c)

"execution (public !int com.whizlabs.spring.questions.aop.SomeClass.*)"

d)

"within(com..*)"

43.
a)

loggers endpoint is exposed by default via both JMX and HTTP

b)

loggers endpoint can be used to list all the loggers in the application

c)

via HTTP an individual logger can be viewed using /actuator/loggers?name=<logger_name>

d)

loggers endpoint can be used to change the logging level of a certain logger.

44.
a)

@SpringBootTest

b)

@Mock

c)

@InjectMocks

d)

@MockBean

45.
a)

findFirst5ById

b)

getFirstFiveById

c)

showFirst5ById

d)

readTop5ById

46.
a)

True

b)

False

47.
a)

Both fat jar and original jar are executable

b)

original jar contains compiled code for an application and also all the dependencies

c)

To create fat-jar the spring-boot-maven-plugin dependency must be set

d)

fat jar contains compiled code for an application without the dependencies

48.
a)

Method annotated with it can handle a POST request in certain cases.

b)

We can replace it using @RequestMapping(method = RequestMethod.GET).

c)

It's a specialization of @RequestMapping.

d)

All of the above.

49.
a)

spring-boot-devtools

b)

spring-boot-actuator

c)

spring-boot-starter-web

d)

spring-boot-starter-security

50.
a)

Spring Boot increases productivity.

b)

Spring Boot increases boilerplate configuration.

c)

Spring Boot simplifies deployment.

d)

Spring Boot doesnt allow creating executable jars.