0% found this document useful (0 votes)
12 views7 pages

SpringbootNotesPDF

The document provides a comprehensive overview of Spring Boot, including its definition, features, and advantages over traditional Spring. It covers key concepts such as microservices, RESTful APIs, and various annotations used in Spring Boot, along with comparisons to Spring MVC and SOAP. Additionally, it discusses tools like Swagger and Spring Initializr, as well as best practices for API development and testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

SpringbootNotesPDF

The document provides a comprehensive overview of Spring Boot, including its definition, features, and advantages over traditional Spring. It covers key concepts such as microservices, RESTful APIs, and various annotations used in Spring Boot, along with comparisons to Spring MVC and SOAP. Additionally, it discusses tools like Swagger and Spring Initializr, as well as best practices for API development and testing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

### SPRING BOOT VIVA QUESTIONS & ANSWERS (Based on Faculty Notes)

---

#### 1. What is Spring Boot?


Spring Boot is an open-source Java-based framework used to create microservices. It allows
building stand-alone, production-grade Spring applications with minimum configurations.

#### 2. Who developed Spring Boot?


It was developed by the Pivotal Team.

#### 3. What are the key features of Spring Boot?


- Minimum configuration
- Embedded Tomcat server
- Production-ready packaging
- Convention over configuration model

#### 4. What does "convention over configuration" mean?


Spring Boot follows defaults and assumptions to minimize the need for configurations.

#### 5. What are the advantages of using Spring Boot?


- Avoids complex XML config
- Easy setup
- Auto-configures beans
- Offers annotation-based development
- Reduces dev time

#### 6. How does Spring Boot help reduce boilerplate code?


By using starter dependencies and auto-configuring beans and components.

#### 7. What is the difference between Spring and Spring Boot?


Spring requires manual setup. Spring Boot provides auto-configurations, embedded servers,
and simplifies development.

#### 8. What are Microservices?


Microservices are independently deployable small services that communicate with each other to
form an application.

#### 9. How are Microservices different from Monolithic architecture?


Monolithic is tightly coupled and deployed as one. Microservices are loosely coupled and
deployed individually.

#### 10. What are the benefits of Microservices?


- Simple scalability
- Faster deployment
- Easy to understand
- High productivity

#### 11. What does "services are autonomous" mean?


Each microservice is developed and deployed independently without affecting others.

#### 12. What are the layers in Spring Boot Architecture?


- Presentation Layer
- Business Layer
- Persistence Layer
- Database Layer

#### 13. What does the Presentation Layer do?


Handles HTTP requests and forwards to the business layer.

#### 14. What does the Business Layer do?


Contains service logic, authorization, and validation.

#### 15. What does the Persistence Layer do?


Handles DB transactions and CRUD logic.

#### 16. What does the Database Layer do?


Executes CRUD operations.

#### 17. Difference between DAO in Spring and Spring Boot?


Spring requires DAO and DAOImpl classes; Spring Boot doesn’t.

#### 18. Compare Spring and Spring Boot.


Spring: Manual config, complex setup.
Spring Boot: Auto-configured, embedded servers, fast dev.

#### 19. Compare Spring Boot and Spring MVC.


Spring MVC: Manual build, deployment descriptors needed.
Spring Boot: Default config, embedded server.

#### 20. What is auto-configuration in Spring Boot?


Spring Boot auto-configures classes based on dependencies.

#### 21. Why is embedded Tomcat useful?


No need for external server installation.

#### 22. What are Spring Boot starters?


Pre-defined dependency sets for various features (web, JPA, security, etc).
#### 23. How do starters help?
Avoid manual dependency management. E.g., spring-boot-starter-web.

#### 24. Give examples of starters.


- spring-boot-starter-web
- spring-boot-starter-data-jpa
- spring-boot-starter-security

#### 25. Naming convention of starters?


All starters follow: spring-boot-starter-*

#### 26. What is @SpringBootApplication?


A combo of @EnableAutoConfiguration, @ComponentScan, and @Configuration.

#### 27. What does @EnableAutoConfiguration do?


Auto-configures the application based on classpath.

#### 28. What is @ComponentScan?


Automatically scans the specified package and its sub-packages.

#### 29. What is @Autowired?


Used for dependency injection at runtime without new keyword.

#### 30. Difference between @RestController and @Controller?


@RestController = @Controller + @ResponseBody (returns JSON/XML not views).

#### 31. What does @RequestMapping do?


Maps HTTP requests to controller methods.

#### 32. What is @ResponseBody?


Binds return values to HTTP response body using converters.

#### 33. Use of @GetMapping/@PostMapping?


Used to map HTTP GET/POST requests to methods.

#### 34. Difference: @RequestParam vs @PathVariable?


@RequestParam = data from URL query string
@PathVariable = data from URI template

#### 35. What does @ResponseStatus do?


Defines the HTTP status returned by a method.

#### 36. What is @Component?


Tells Spring to automatically detect and register class as a bean.

#### 37. What are web services?


Open standards/protocols that allow applications to exchange data (via HTTP).

#### 38. What are data exchange formats in web services?


XML and JSON

#### 39. What is XML?


Structured markup language used in SOAP.

#### 40. What is JSON?


Lightweight, human-readable data format. Popular with REST.

#### 41. What is a service definition?


It defines request/response formats, structure, and endpoint.

#### 42. What are the characteristics of web services?


- XML-based
- Loosely coupled
- Platform-independent

#### 43. What is loosely coupled?


Services communicate without tight binding.

#### 44. Real-world example of web service?


ICICI ATM using SBI DB via web service.

#### 45. What is SOAP?


Protocol using XML. Strict and heavy. Uses WSDL.

#### 46. What is REST?


Architectural style using HTTP and JSON. Lightweight.

#### 47. Difference between SOAP & REST?


SOAP = protocol, strict, uses XML
REST = style, flexible, uses JSON/XML

#### 48. Why is REST preferred?


Lightweight, faster, less bandwidth.

#### 49. HTTP methods in REST?


GET, POST, PUT, PATCH, DELETE
#### 50. Common HTTP status codes?
- 200 OK
- 201 Created
- 400 Bad Request
- 404 Not Found

#### 51. What is RESTful API?


API that follows REST principles using HTTP.

#### 52. How to define endpoints?


Use @RestController with mappings.

#### 53. What is Spring Initializr?


Tool to bootstrap Spring Boot project.

#### 54. How does Spring handle GET requests?


Using @GetMapping to return data (JSON/XML).

#### 55. How about POST/PUT/DELETE?


POST = create, PUT = update, DELETE = remove.

#### 56. What is Swagger UI?


Interactive UI to test and document REST APIs.

#### 57. How to access Swagger?


http://localhost:8080/swagger-ui/index.html

#### 58. What does 200 OK in Swagger mean?


Successful response.

#### 59. What is DTO?


Data Transfer Object for passing data efficiently.

#### 60. Why use DTO?


Avoid multiple calls, group data, hide internal model.

#### 61. Benefit of DTO over entities?


Secure, compact data transfer.

#### 62. What is ORM?


Object-Relational Mapping. Maps Java objects to DB tables.

#### 63. What is JPA?


Java Persistence API. It’s a specification.
#### 64. What is Hibernate?
Implementation of JPA.

#### 65. What is Spring Data JPA?


Spring abstraction over JPA providers like Hibernate.

#### 66. What is JpaRepository?


Interface with built-in CRUD, pagination, and sorting.

#### 67. Syntax for JpaRepository?


public interface XRepo extends JpaRepository<X, ID>

#### 68. Role of application.properties?


Stores configuration (DB details, port, etc.)

#### 69. What is H2 database?


In-memory DB used for testing.

#### 70. What is pom.xml?


Maven file to manage project dependencies and config.

#### 71. What is the .m2 folder?


Local repo storing Maven dependencies.

#### 72. What is RestTemplate?


Used to consume REST APIs from other services.

#### 73. What is EntityResponse?


Represents complete HTTP response with status, body, and headers.

#### 74. What is Dev Tools?


Auto reloads app on changes for faster development.

#### 75. Why prefer RestController over Controller?


Simpler to return data (JSON/XML) directly.

#### 76. What is Lombok?


Java library to reduce boilerplate (getters/setters).

#### 77. Why use @RestController?


To handle REST requests and return JSON/XML directly.

#### 78. How to test APIs?


Using Swagger or hitting endpoints in browser/Postman.

#### 79. How does @RequestBody work?


Maps HTTP request body to a Java object.

#### 80. What is @PostMapping?


Handles HTTP POST requests.

#### 81. How to return 201 CREATED status?


Use @ResponseStatus(HttpStatus.CREATED)

#### 82. How to send query params?


Use @RequestParam in controller method.

#### 83. How to send path variables?


Use @PathVariable in controller method.

#### 84. How do you handle exceptions?


By creating a class extending RuntimeException.

#### 85. How to consume endpoints?


Using RestTemplate or API clients like Postman.

You might also like