Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is an IOC container?

Answer»

IoC CONTAINER is a framework for implementing automatic DEPENDENCY INJECTION. It manages OBJECT creation and its life-time and also injects dependencies into the class.

2.

Where do we define properties in the Spring Boot application?

Answer»

You can define both application and Spring boot-related PROPERTIES into a file called application.properties. You can create this file manually or USE Spring Initializer to create this file. You don’t need to do any SPECIAL configuration to instruct Spring Boot to load this file, If it exists in classpath then spring boot automatically loads it and configure itself and the application code ACCORDINGLY.

3.

How to enable debugging log in the spring boot application?

Answer»

Debugging logs can be enabled in three ways -

  • We can start the APPLICATION with --DEBUG switch.
  • We can set the LOGGING.level.ROOT=debug property in application.property file.
  • We can set the logging level of the root logger to debug in the SUPPLIED logging configuration file.
4.

How to check the environment properties in your Spring boot application?

Answer»

Spring BOOT actuator “/ENVRETURNS the list of all the environment PROPERTIES of RUNNING the spring boot application.

5.

How to get the list of all the beans in your Spring boot application?

Answer»

SPRING BOOT actuator “/Beans” is used to GET the LIST of all the spring beans in your application.

6.

What are the actuator-provided endpoints used for monitoring the Spring boot application?

Answer»

ACTUATORS PROVIDE below pre-defined ENDPOINTS to MONITOR our APPLICATION -

  • Health
  • Info
  • Beans
  • Mappings
  • Configprops
  • Httptrace
  • Heapdump
  • Threaddump
  • Shutdown
7.

How to enable Actuator in Spring boot application?

Answer»

To ENABLE the spring actuator feature, we NEED to add the DEPENDENCY of “spring-boot-starter-actuator” in pom.xml.

<dependency&GT;<groupId> org.springframework.boot</groupId><artifactId> spring-boot-starter-actuator </artifactId></dependency>
8.

What is Spring Actuator? What are its advantages?

Answer»

An actuator is an additional feature of Spring that helps you to monitor and manage your APPLICATION when you PUSH it to production. These actuators include auditing, HEALTH, CPU usage, HTTP hits, and metric GATHERING, and many more that are automatically applied to your application.

9.

What is the use of Profiles in spring boot?

Answer»

While developing the application we deal with multiple environments such as dev, QA, PROD, and each ENVIRONMENT requires a different CONFIGURATION. For eg., we might be using an embedded H2 database for dev but for prod, we might have proprietary Oracle or DB2. Even if DBMS is the same across the environment, the URLS will be different.

To make this EASY and clean, Spring has the provision of Profiles to keep the separate configuration of environments.

10.

What is the difference between RequestMapping and GetMapping?

Answer»

RequestMapping can be used with GET, POST, PUT, and many other request methods using the method attribute on the ANNOTATION. Whereas getMapping is only an EXTENSION of RequestMapping which helps you to improve on CLARITY on request.

11.

Describe the flow of HTTPS requests through the Spring Boot application?

Answer»

On a high-level spring BOOT APPLICATION follow the MVC pattern which is depicted in the below flow diagram.

Spring Boot Flow ARCHITECTURE
12.

What is the difference between @RestController and @Controller in Spring Boot?

Answer»

@Controller MAP of the model object to VIEW or template and make it human READABLE but @RestController simply returns the object and object data is DIRECTLY WRITTEN in HTTP response as JSON or XML.

13.

Explain @RestController annotation in Sprint boot?

Answer»

It is a combination of @CONTROLLER and @ResponseBody, used for CREATING a restful controller. It converts the response to JSON or XML. It ENSURES that data RETURNED by each method will be written straight into the response body instead of returning a template.

14.

How to disable a specific auto-configuration class?

Answer»

You can USE EXCLUDE ATTRIBUTE of @EnableAutoConfiguration if you WANT auto-configuration not to apply to any specific class.

//use of exclude@EnableAutoConfiguration(exclude={className})
15.

Can we disable the default web server in the Spring boot application?

Answer»

YES, we can use application.properties to CONFIGURE the WEB application TYPE i.e spring.main.web-application-type=none.

16.

Can we override or replace the Embedded tomcat server in Spring Boot?

Answer»

YES, we can replace the Embedded Tomcat server with any server by using the Starter DEPENDENCY in the pom.xml file. LIKE you can use spring-boot-starter-JETTY as a dependency for using a jetty server in your PROJECT.

17.

What is the default port of tomcat in spring boot?

Answer»

The DEFAULT PORT of the TOMCAT server-id 8080. It can be CHANGED by adding sever.port properties in the application.property file.

18.

Is it possible to change the port of the embedded Tomcat server in Spring Boot?

Answer»

YES, it is POSSIBLE. By USING the server.port in the application.properties.

19.

Can we create a non-web application in Spring Boot?

Answer»

Yes, we can create a non-web application by removing the web dependencies from the classpath along with CHANGING the WAY SPRING BOOT creates the application context.

20.

What is Spring Boot dependency management?

Answer»

Spring Boot dependency MANAGEMENT is used to MANAGE DEPENDENCIES and configuration automatically WITHOUT you SPECIFYING the version for any of that dependencies.

21.

What Are the Basic Annotations that Spring Boot Offers?

Answer»

The primary annotations that Spring BOOT offers reside in its org.springframework.boot.autoconfigure and its sub-packages. Here are a couple of basic ones:

@EnableAutoConfiguration – to MAKE Spring Boot LOOK for auto-configuration beans on its classpath and automatically APPLY them.

@SpringBootApplication – USED to denote the main class of a Boot Application. This annotation combines @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations with their default attributes.