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

SpringBoot_Viva_Detailed_CheatSheet

The document is a detailed cheat sheet for Spring Boot and related topics, covering key concepts such as Spring Boot's purpose, microservices architecture, REST vs SOAP APIs, and various Spring annotations. It explains the roles of components like EntityManager in JPA, the use of DTOs, and the structure of Spring MVC layers. Additionally, it addresses HTTP methods and their appropriate use cases, providing a comprehensive overview for quick reference.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SpringBoot_Viva_Detailed_CheatSheet

The document is a detailed cheat sheet for Spring Boot and related topics, covering key concepts such as Spring Boot's purpose, microservices architecture, REST vs SOAP APIs, and various Spring annotations. It explains the roles of components like EntityManager in JPA, the use of DTOs, and the structure of Spring MVC layers. Additionally, it addresses HTTP methods and their appropriate use cases, providing a comprehensive overview for quick reference.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Spring Boot & Related Topics - Detailed Viva Cheat Sheet

Spring Boot Introduction


Q: What is Spring Boot?
A: Spring Boot is an extension of the Spring framework that simplifies the process of setting up and developing new
Spring applications by reducing boilerplate code. It provides production-ready defaults and embedded servers like
Tomcat or Jetty.
Q: Why use Spring Boot?
A: To create stand-alone, production-grade Spring applications quickly. It reduces development time and increases
productivity through auto-configuration and starter templates.
Q: What are Starters in Spring Boot?
A: Starters are a set of convenient dependency descriptors you can include in your application. For example,
spring-boot-starter-web for building web apps.

Microservices
Q: What are Microservices?
A: Microservices is an architectural style that structures an application as a collection of small autonomous services,
modeled around a business domain.
Q: How do microservices communicate?
A: They usually communicate using HTTP (REST APIs) or messaging queues like RabbitMQ, Kafka.
Q: Challenges with microservices?
A: Service coordination, distributed transactions, monitoring, logging, network latency, and data consistency.

REST, Web, and SOAP APIs


Q: Difference between REST and SOAP?
A: REST uses HTTP with JSON/XML, is lightweight and stateless. SOAP is a protocol, uses XML, is heavier, and has
stricter rules with built-in security and transaction compliance.
Q: Advantages of REST APIs?
A: Statelessness, scalability, cacheable responses, easy to test and integrate.

Spring Annotations
Q: @Component vs @Bean?
A: @Component is a class-level annotation used for automatic component scanning. @Bean is used at the method level
to define a bean explicitly in a configuration class.
Q: @RequestMapping vs @GetMapping?
A: @RequestMapping is a generic mapping for all HTTP methods. @GetMapping is a shortcut for
@RequestMapping(method = RequestMethod.GET).

JPA & JPQL


Q: What is the role of EntityManager?
A: EntityManager is the primary JPA interface for interacting with the persistence context. It manages entity life cycles
and performs operations like persist, merge, remove.
Q: Examples of JPQL?
A: SELECT e FROM Employee e WHERE e.salary > 50000

Swagger API
Q: What is the purpose of Swagger UI?
A: It provides a visual interface for interacting with REST APIs and helps with auto-generating documentation using
annotations like @Api, @ApiOperation.

HTTP Methods
Q: When to use POST vs PUT?
A: POST is used to create new resources. PUT is used to update or replace existing resources.
Q: Is DELETE idempotent?
A: Yes, calling DELETE multiple times will result in the same outcome.

Spring Mapping Annotations


Q: What is @RequestBody?
A: It maps the HTTP request body to a transfer or domain object in the method parameter.
Q: What is @RequestParam?
A: It binds a web request parameter to a method parameter.

DTO & ResponseEntity


Q: Why use DTOs?
A: DTOs help decouple the API layer from the internal data model. They prevent overexposing sensitive data.
Q: What does ResponseEntity.ok() do?
A: It returns an HTTP 200 OK response with a body.

Spring MVC Layers


Q: Explain Controller-Service-Repository architecture.
A: Controller handles requests, Service layer contains business logic, Repository layer handles database interactions
using JPA interfaces.
Q: What is @Transactional?
A: It marks a method or class for transaction management. Ensures commit/rollback based on method success or
failure.

You might also like