0% found this document useful (0 votes)
7 views

SpringBoot_Flashcards

Spring Boot is an open-source Java framework that simplifies the development of standalone applications by reducing boilerplate code and providing features like auto-configuration and embedded servers. Key concepts include annotations such as @SpringBootApplication, @RestController, and @Autowired, as well as the use of DTOs for data transfer. The document also covers RESTful services, JPA, and tools like Swagger for API documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SpringBoot_Flashcards

Spring Boot is an open-source Java framework that simplifies the development of standalone applications by reducing boilerplate code and providing features like auto-configuration and embedded servers. Key concepts include annotations such as @SpringBootApplication, @RestController, and @Autowired, as well as the use of DTOs for data transfer. The document also covers RESTful services, JPA, and tools like Swagger for API documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Spring Boot Flashcards - Viva Prep

Q: What is Spring Boot? How does it differ from the traditional Spring Framework?
A: Spring Boot is an open-source Java-based framework used to build standalone and production-ready

Spring applications. Unlike traditional Spring, Spring Boot reduces boilerplate code, provides

auto-configuration, embedded servers, and avoids XML configurations.

Q: What are the main features of Spring Boot?


A: - Auto-configuration

- Embedded servers (like Tomcat, Jetty)

- Starter dependencies

- Minimal configuration

- Production-ready metrics and health checks

Q: Explain the term "Convention over Configuration" in Spring Boot.


A: Spring Boot prefers sensible defaults and reduces the need for manual configuration. If the structure and

naming follow conventions, Spring Boot auto-configures components.

Q: What are some advantages of using Spring Boot over Spring MVC?
A: - No need for XML config

- Embedded server support

- Faster development

- Auto dependency management with starters

- Easier testing and deployment

Q: Compare Monolithic Architecture and Microservices.


A: - Monolithic: All modules are tightly coupled and deployed as a single unit.

- Microservices: Each service is independent, loosely coupled, and can be deployed separately.

Q: What is @SpringBootApplication?
A: It is a convenience annotation that combines @Configuration, @EnableAutoConfiguration, and

@ComponentScan. It marks the main class of a Spring Boot application.


Spring Boot Flashcards - Viva Prep

Q: How does @RestController differ from @Controller?


A: @RestController returns data (JSON/XML) directly, combining @Controller and @ResponseBody.

@Controller is used for traditional web applications that return views (HTML/JSP).

Q: Explain the use of @RequestMapping and @GetMapping.


A: @RequestMapping is a general-purpose annotation to handle all HTTP methods.

@GetMapping is a shortcut for @RequestMapping(method = RequestMethod.GET).

Q: What is the purpose of @Autowired in Spring Boot?


A: It injects dependencies automatically into Spring-managed beans using Spring's dependency injection.

Q: What is the difference between @PathVariable and @RequestParam?


A: @PathVariable binds data from URL path segments.

@RequestParam binds data from query parameters.

Q: What is the use of the pom.xml file in a Spring Boot project?


A: It defines project dependencies, plugins, build configuration, and metadata for Maven-based Spring Boot

projects.

Q: What are Spring Boot Starters? Can you name a few?


A: Starters are dependency descriptors for Spring Boot. Examples: spring-boot-starter-web,

spring-boot-starter-data-jpa, spring-boot-starter-security.

Q: What is the role of the application.properties file?


A: It holds application-level configuration such as server port, database settings, and logging levels.

Q: What happens when we run spring-boot:run?


A: Maven runs the Spring Boot application by executing the main class and bootstrapping the embedded

server.
Spring Boot Flashcards - Viva Prep

Q: What is RESTful Web Service? How is it different from SOAP?


A: REST uses standard HTTP methods and data formats like JSON. It is lightweight and stateless. SOAP is a

strict protocol using XML and requires more overhead.

Q: What HTTP methods are commonly used in REST APIs and what do they represent?
A: - GET: Read data

- POST: Create data

- PUT: Update/replace data

- PATCH: Modify data

- DELETE: Remove data

Q: What is the purpose of the @RequestBody and @ResponseBody annotations?


A: - @RequestBody: Maps request JSON to Java object.

- @ResponseBody: Converts Java object to JSON/response.

Q: How does Spring Boot return JSON as a response?


A: By default, Spring Boot uses Jackson to convert Java objects to JSON when using @RestController or

@ResponseBody.

Q: What is JPA? How is it related to Hibernate?


A: JPA (Java Persistence API) is a specification for ORM. Hibernate is its implementation. JPA allows

mapping Java objects to database tables.

Q: What is JpaRepository? What are some methods provided by it?


A: JpaRepository extends CrudRepository and provides methods like save(), findAll(), findById(), delete(),

count().

Q: What is ORM? How does it help in persistence?


A: ORM (Object-Relational Mapping) lets developers persist Java objects directly into relational databases
Spring Boot Flashcards - Viva Prep

using mappings. It simplifies DB operations.

Q: What is Swagger and why is it used?


A: Swagger is a tool for documenting and testing REST APIs. It provides an interactive UI to test endpoints.

Q: How do you access Swagger UI in a Spring Boot application?


A: By visiting http://localhost:8080/swagger-ui/index.html after configuring Swagger dependencies.

Q: What is the HTTP response code 201? When is it returned?


A: 201 Created is returned when a new resource is successfully created, typically after a POST request.

Q: How would you create a REST endpoint that returns a list of students?
A: Create a @RestController, use @GetMapping("/students"), and return List<Student> from the handler

method.

Q: What steps will you follow to resolve Maven dependency issues?


A: - Replace http with https in pom.xml

- Update local repository path in .m2/settings.xml

- Do a Maven > Update Project with Force Update enabled

Q: How does Spring Boot handle auto-configuration?


A: Spring Boot auto-configures beans based on the classpath and uses @EnableAutoConfiguration internally

to provide defaults.

Q: What are DTOs and why are they used?


A: DTOs (Data Transfer Objects) are used to transfer data between layers without exposing the internal

structure of entities. They improve encapsulation and reduce API payload.

You might also like