Spring Boot Framework Interview Question-Answer

Q.1 Which of the following is correct about dependency injection?

       A. It helps in decoupling application objects from each other

       B. It stores object states in the file system

       C. It helps in deciding the dependencies of objects

       D. It stores object states in the database

Ans : It helps in decoupling application objects from each other


Q.2 A session scope scopes the bean definition to an/the ____________.

       A. Spring IoC container

       B. HTTP request

       C. HTTP session

       D. HTTP Application/Global session

Ans : HTTP session


Q.3 Which of the following methods performs the initialization of a bean?

       A. afterPropertiesSet

       B. init

       C. constructor

       D. initialize

Ans : init


Q.4 Which layer of spring boot spans across multiple layers?

       A. Foundation layer

       B. Web layer

       C. Service layer

       D. Common layer

Ans : Foundation layer


Q.5 The following are valid techniques to offer configuration metadata to spring container, except ________.

       A. Annotation-based configuration

       B. XML-based configuration file

       C. JSON-based configuration file

       D. Java-based configuration

Ans : JSON-based configuration file


Q.6 Which method should a bean implement to employ destruction callbacks?

       A. clear

       B. clean

       C. destroy

       D. finalize

Ans : destroy


Q.7 Which interface implements Destruction callbacks?

       A. FinalizerBean

       B. DisposableBean

       C. DestructorBean

       D. DemolishBean

Ans : DisposableBean


Q.8 Which interface helps to initialize the bean?

       A. BeanInitializer

       B. BeanInitializing

       C. InitializerBean

       D. InitializingBean

Ans : InitializingBean


Q.9 The Maven command to run a Spring boot application is __________.

       A. mvn spring-boot:run

       B. maven spring-boot:run

       C. Mvn spring: run

       D. None of the options

Ans : mvn spring-boot:run


Q.10 ‘Spring-boot-maven-plugin’ is added to the pom.xml plugin section to _____________.

       A. Package the spring boot application as an executable jar

       B. Boot the maven Spring boot application

       C. Build a maven Spring boot application

       D. None of the options

Ans : Package the spring boot application as an executable jar


Q.11 The annotation to be added to automatically configure beans based on the classes added to the class path is ____________.

       A. @EnableConfiguration

       B. @EnableAutoConfiguration

       C. @AutoConfiguration

       D. None of the options

Ans : @EnableAutoConfiguration


Q.12 The default Java compiler level for a Spring boot app is __________.

       A. Java 1.6

       B. Java 1.8

       C. Java 1.7

       D. None of the options

Ans : Java 1.6


Q.13 What does SpringApplication.run() do?

       A. Default configuration

       B. Starts Tomcat Server

       C. Starts Spring Application Context

       D. Performs class path scan (interprets all annotations in the Spring class)

       E. All the options

Ans : All the options


Q.14 The Java compiler level can be modified for a Maven built Spring boot app using ____________.

       A. server.properties

       B. application.properties

       C. web.xml

       D. pom.xml

Ans : pom.xml


Q.15 Executable jar can be created in Spring boot using __________.

       A. Maven build

       B. Gradle build

       C. Both the options

       D. None of the options

Ans : Both the options


Q.16 Spring boot application can be executed as a stand-alone jar.

       A. True

       B. False

Ans : True


Q.17 Dependencies cannot be added to the Gradle build system in Spring boot.

       A. True

       B. False

Ans : False


Q.18 What is the starter for using log4j2 for logging?

       A. Spring-boot-starter-logger

       B. Spring-boot-starter-log

       C. Spring-boot-starter-log4j2

       D. None of the options

Ans : Spring-boot-starter-log4j2


Q.19 Spring-boot-starter-parent allows to manage __________.

       A. Configuration – Java Version and other properties

       B. Dependency Management – Version of dependencies

       C. Default Plugin Configuration

       D. All the options

Ans : All the options


Q.20 Spring boot starter for a Spring batch application is ____________.

       A. Spring-starter-batch

       B. Spring-boot-batch

       C. Spring-boot-starter-batch

       D. None of the options

Ans : Spring-boot-starter-batch


Q.21 Which annotation is used to bind application properties to the class fields?

       A. @ApplicationProperties

       B. @ConfigurationProperties

       C. @AppProperties

       D. None of the options

Ans : @ConfigurationProperties


Q.22 Spring boot does not auto configure when a jar dependency is added outside the Starters package.

       A. True

       B. False

Ans : False


Leave a Comment

Your email address will not be published. Required fields are marked *