Table of Content
Basic Java - 4 days
Day 1: Introduction to Java
• Topics:
o Overview of Java and its Features
o Setting up the Development Environment (JDK, IDE, and Build Tools)
o Understanding JVM, JRE, and JDK
o Basic Syntax:
▪ Data Types and Variables
▪ Operators (Arithmetic, Relational, Logical)
▪ Input and Output (Scanner and [Link])
o Control Flow Statements:
▪ Conditional Statements (if, if-else, switch)
▪ Loops (for, while, do-while)
• Hands-On:
o Write a program to check if a number is prime.
o Create a simple menu-driven program using switch.
Day 2: Object-Oriented Programming (OOP) Concepts
• Topics:
o Basics of Classes and Objects
o Constructors (Default, Parameterized)
o OOP Principles:
▪ Encapsulation
▪ Inheritance (Single, Multilevel)
▪ Polymorphism (Method Overloading and Method Overriding)
▪ Abstraction (Abstract Classes)
o this and super Keywords
• Hands-On:
o Create a program to model a BankAccount class with methods like deposit, withdraw,
and checkBalance.
o Implement inheritance by extending BankAccount to SavingsAccount and
CurrentAccount.
Day 3: Advanced Topics
• Topics:
o Static Members and Methods
o Access Modifiers (private, protected, public, default)
o Arrays and Array Operations
o String Handling:
▪ String Methods (length, substring, replace, etc.)
▪ StringBuilder and StringBuffer
o Introduction to Exception Handling:
▪ try, catch, finally
▪ Custom Exceptions
• Hands-On:
o Develop a program to perform CRUD operations on an array of student records.
o Write a program to handle division by zero using exception handling.
Day 4: Collections and Functional Programming
Topics:
o Collections Framework:
▪ Lists (ArrayList, LinkedList)
▪ Sets (HashSet, TreeSet)
▪ Maps (HashMap, TreeMap), equals , hashcode
o Introduction to Streams API
o Lambda Expressions and Functional Interfaces ( Predicate, Function, Consumer)
• Hands-On:
o Create a program to sort and filter a list of employees using Streams.
o Implement a program to group words by their lengths using HashMap.
Junit test
1. What is JUnit?
• Overview of JUnit framework
• Importance of unit testing in software development
• Integration with IDEs (Eclipse, IntelliJ, VS Code)
2. Setting up JUnit
• Adding JUnit dependency to a Maven/Gradle project
• Overview of JUnit 4 vs. JUnit 5
3. Key Features of JUnit
• Annotations: @Test, @BeforeEach, @AfterEach, etc.
• Test lifecycle management
2. Writing Basic Unit Tests
1. Anatomy of a Unit Test
• Structure of a test case
• Assertions using [Link], assertTrue, etc.
2.2. Testing Business Logic
• Writing tests for simple methods (e.g., arithmetic or string operations)
2.3. Parameterized Tests
• Introduction to @ParameterizedTest
• Writing reusable test cases with different inputs
2.4. Handling Exceptions in Tests
• Using assertThrows to test exception handling
Angular – 3 days
Day 1: Angular Basics and Project Setup
Topics:
1. Introduction to Angular:
o What is Angular? Key features and advantages.
o Angular vs other frameworks (React, Vue).
2. Setting Up the Development Environment:
o Installing [Link], npm, and Angular CLI.
o Creating your first Angular application.
3. Project Structure Overview:
o Understanding the folder and file hierarchy.
o Roles of src, app, assets, and [Link].
4. Core Concepts:
o Modules (@NgModule) and Components (@Component).
o Templates and styles.
o Data Binding:
▪ Property binding.
▪ Event binding.
▪ Two-way binding with [(ngModel)].
5. Angular Directives:
o Structural directives: *ngIf, *ngFor.
o Attribute directives: ngClass, ngStyle.
Hands-On:
• Create a simple Angular app to display a list of products using *ngFor.
• Add a button to toggle product availability using *ngIf and event binding.
Day 2: Services, Routing, and Forms
Topics:
1. Services and Dependency Injection:
o Creating and using services.
o Injecting services into components using the constructor.
o Sharing data between components with services.
2. Routing and Navigation:
o Setting up Angular Router.
o Configuring routes with RouterModule and Routes.
o Navigating between pages using routerLink and [Link].
o Passing parameters between routes.
3. Forms in Angular:
o Template-driven forms:
▪ Using FormsModule.
▪ Form validation (required, minLength, etc.).
o Reactive forms:
▪ Using FormBuilder and FormGroup.
▪ Custom validators.
Hands-On:
• Build a multi-page Angular app:
o Add routing for Home, Products, and About pages.
o Pass product IDs as route parameters to a detailed product page.
• Create a product submission form with validation using template-driven forms.
Day 3: HTTP Client, Observables, and Deployment
Topics:
1. HTTP Client:
o Setting up HttpClientModule.
o Making GET, POST, PUT, and DELETE requests.
o Error handling with HttpErrorResponse.
o Using observables (Observable) with HTTP requests.
2. Component Communication:
o Parent-to-child communication using @Input.
o Child-to-parent communication using @Output and EventEmitters.
Hands-On:
• Build a product catalog application:
o Fetch product data from a mock API (e.g., JSONPlaceholder).
o Display product details dynamically.
o Add features to create, edit, and delete products using HTTP methods.
SpringBoot – 3 days
Day 1: Spring Boot Fundamentals and REST API Basics
Topics:
1. Introduction to Spring Boot:
o What is Spring Boot?
o Why Spring Boot? Key Features and Benefits.
o Differences between Spring and Spring Boot.
2. Setting Up the Environment:
oInstalling JDK, Maven/Gradle, and IDE (IntelliJ/Eclipse).
oCreating your first Spring Boot project using Spring Initializer.
3. Understanding Spring Boot Architecture:
o Project structure overview.
o Key annotations: @SpringBootApplication, @Component, @Service,
@RestController.
4. Building a Simple REST API:
o Basics of @GetMapping, @PostMapping, @PutMapping, and @DeleteMapping.
o Handling path variables and query parameters.
5. Running and Testing Your API:
o Using Postman for testing.
o Introducing Swagger/OpenAPI for API documentation.
Hands-On:
• Create a "Hello World" REST API.
• Build a simple "Task Manager" API with endpoints for creating, viewing, updating, and deleting
tasks.
Day 2: Database Integration and CRUD Operations
Topics:
1. Introduction to Spring Data JPA:
o What is JPA, and why use it?
o Setting up H2/MySQL database in Spring Boot.
o Writing Entity classes and mapping (@Entity, @Id, @GeneratedValue).
2. Spring Data Repositories:
o Using JpaRepository for CRUD operations.
o Writing custom queries with JPQL and derived query methods.
3. Database Interactions:
o Persisting, retrieving, updating, and deleting records.
o Handling relationships: One-to-Many, Many-to-One.
4. Error and Exception Handling:
o Global exception handling with @ControllerAdvice.
o Custom exceptions for specific error scenarios.
5. Exploring the [Link] Configuration File.
Hands-On:
• Extend the "Task Manager" API to:
o Save tasks in a database.
o Add endpoints for filtering tasks by status (e.g., pending/completed).
• Implement global error handling for invalid API inputs.
Day 3: Advanced Features and Practical Enhancements
Topics:
1. Input Validation:
o Validating user input with @Valid, @NotNull, @Size, etc.
o Handling validation errors with custom responses.
2. Pagination and Sorting:
o Using Pageable and Page objects to paginate API responses.
o Adding sorting capabilities.
3. Spring Boot Profiles and Configuration:
o Using [Link] for better readability.
o Working with Spring Profiles (dev, prod) for environment-specific configurations.
4. Securing REST APIs:
o Basics of Spring Security.
o Adding Basic Authentication to your API.
5. Introduction to Deployment:
o Packaging Spring Boot apps as JAR files.
o Running Spring Boot apps on local/remote servers.
Hands-On:
• Enhance the "Task Manager" API to:
o Add input validation for task creation (e.g., task name should be non-empty).
o Implement pagination and sorting for viewing tasks.
o Secure the API with Basic Authentication.
• Deploy the application locally and test it.
Practice Questions
Day 1: Introduction to Java
Practice Questions:
1. Write a program to check whether a given year is a leap year.
2. Develop a calculator program that performs addition, subtraction, multiplication, and
division based on user input.
3. Write a program to find the largest and smallest numbers in an array.
4. Create a menu-driven program to calculate the area of a circle, rectangle, and triangle.
5. Print the Fibonacci series up to a given number using a loop.
Day 2: Object-Oriented Programming (OOP) Concepts
Practice Questions:
1. Create a Student class with properties like name, rollNumber, and marks. Implement
methods to display and update the student details.
2. Implement a Vehicle class with subclasses Car and Bike. Demonstrate method overriding
by overriding a startEngine method in the subclasses.
3. Write a program to model a Library system:
o Create a Book class with properties like title, author, and ISBN.
o Create methods to add, remove, and display books.
4. Use constructors to initialize objects of a Person class. Include both default and
parameterized constructors.
5. Write a program that demonstrates the use of this and super in a scenario involving
inheritance.
Day 3: Advanced Topics
Practice Questions:
1. Write a program to reverse a string without using built-in methods.
2. Develop a program that takes an array of integers and removes all duplicates.
3. Create a program to count the frequency of characters in a given string.
4. Write a custom exception class InvalidAgeException that gets triggered when a user enters
an invalid age for voting eligibility.
5. Develop a program to find the second largest number in an array.
Day 4: Collections and Functional Programming
Practice Questions:
1. Write a program to store student names in an ArrayList and perform the following
operations:
o Add a name
o Remove a name
o Sort the list alphabetically
2. Create a HashSet to store unique employee IDs. Write a program to add employee IDs
and check if a specific ID exists in the set.
3. Develop a program using a HashMap to store a list of countries and their capitals.
Implement methods to add, retrieve, and display the entries.
4. Write a program that uses Streams to:
o Filter out numbers greater than 10 from a list.
o Sort the filtered numbers in descending order.
5. Use a lambda expression to implement a Comparator that sorts a list of strings by their
lengths.
Angular Practice Questions
1. Create an Angular application to display a welcome message like “Welcome to [Your
Name]’s Angular App” using a component.
2. Build a component to display a list of products (e.g., name, price, availability) using
*ngFor.
3. Add a button to toggle the availability of each product using *ngIf and property binding.
4. Use ngClass to highlight products that are out of stock with a red background.
5. Add an input field and a button to allow the user to add new products to the list
dynamically.
Day 2: Services, Routing, and Forms
Services and Dependency Injection
1. Create a service to provide a list of employees. Inject the service into a component to
display employee details.
2. Modify the service to add a method that allows adding a new employee to the list and
use it in the component.
Routing and Navigation
3. Set up routing in an Angular app with Home, Products, and Contact pages. Use routerLink to
navigate between them.
4. Add a route for a Product Details page that takes a product ID as a parameter. Display
product details dynamically based on the route parameter.
5. Redirect users to the Home page when they navigate to an invalid route (404 handling).
Forms
6. Create a template-driven form for user registration with the following fields:
o Name (required, minimum 3 characters).
o Email (required, must be a valid email).
o Password (required, minimum 6 characters).
7. Use a reactive form to create a login form with the same fields and validations as above.
Add a custom validator for confirming passwords.
8. Display error messages dynamically when a user enters invalid data in the form.
Day 3: HTTP Client, Observables, and Deployment
HTTP Client
1. Fetch a list of users from a public API (e.g., JSONPlaceholder) and display it in a
component.
2. Implement a feature to add a new user to the list using a POST request.
3. Create an edit button for each user to update their details using a PUT request.
4. Add a delete button to remove a user from the list using a DELETE request.
Component Communication
5. Use @Input to pass a product object from a parent component to a child component for
detailed display.
6. Use @Output and EventEmitter to allow the child component to notify the parent when a
product is added, edited, or deleted.
7. Create a shared service to manage product data and use it for communication between
sibling components
Spring Boot Fundamentals and REST API Basics
Practice Questions:
1. Create a Spring Boot application with a simple REST API to return "Welcome to Spring
Boot!".
2. Build an API to manage a list of books:
o Add a new book (POST).
o Retrieve a list of all books (GET).
o Update the details of a book using its ID (PUT).
o Delete a book by ID (DELETE).
3. Modify the above API to accept query parameters for filtering books by author or
category.
4. Write a REST API to calculate the factorial of a number passed as a path variable.
Segment 2: Database Integration and CRUD Operations
Practice Questions:
1. Set up an MySQL database in your Spring Boot application.
2. Create an Employee entity with fields: id, name, department, and salary. Use JPA to:
o Save a new employee.
o Retrieve all employees.
o Update an employee's department.
o Delete an employee by ID.
3. Write a custom query using JPQL to:
o Find employees with a salary greater than a given amount.
o Retrieve all employees in a specific department.
4. Enhance the "Task Manager" API:
o Add persistence using a database.
o Implement filtering tasks by status (e.g., pending, completed) using a custom
query.
Segment 3: Advanced Features and Enhancements
Practice Questions:
1. Implement input validation for the "Task Manager" API:
o Ensure the task name is not blank and has a minimum length of 3 characters.
o Validate that the due date is in the future.
2. Add pagination and sorting to the "Task Manager" API:
o Paginate tasks with customizable page size.
o Sort tasks by due date or status.
3. Configure Spring Profiles (dev and prod):
o Use different database configurations for development and production
environments.
o Test switching between profiles.
4. Secure the "Task Manager" API:
o Protect all endpoints using Basic Authentication.
o Create two roles (ADMIN, USER) and restrict access to specific endpoints based on
roles.
Assessment Questions
Basic Java MCQs
Pre-Test MCQs
1. Which of these is not a Java keyword?
a) static
b) goto
c) final
d) main
Answer: d) main
2. What is the default value of a boolean in Java?
a) true
b) false
c) null
d) 0
Answer: b) false
3. Which operator is used to compare two values in Java?
a) =
b) ==
c) !=
d) <
Answer: b) ==
4. Which data type is used to store decimals in Java?
a) int
b) float
c) double
d) Both b and c
Answer: d) Both b and c
5. What is an object in Java?
a) A variable
b) A class
c) An instance of a class
d) A method
Answer: c) An instance of a class
6. What does the String class in Java represent?
a) A primitive data type
b) An array
c) A sequence of characters
d) None of the above
Answer: c) A sequence of characters
7. Which of the following is used to declare constants in Java?
a) const
b) define
c) final
d) static
Answer: c) final
8. What is the output of 10 % 3 in Java?
a) 1
b) 3
c) 0
d) undefined
Answer: a) 1
9. Which of these is not a valid loop in Java?
a) for
b) do-while
c) foreach
d) while
Answer: c) foreach
10. Which keyword is used to refer to the current object in Java?
a) this
b) that
c) super
d) self
Answer: a) this
11. What is JVM in Java?
a) Java Virtual Machine
b) Java Verification Model
c) Java Version Manager
d) None of the above
Answer: a) Java Virtual Machine
12. Which package contains the Scanner class?
a) [Link]
b) [Link]
c) [Link]
d) [Link]
Answer: a) [Link]
13. What is the correct syntax to declare an array in Java?
a) int[] arr = new int[5];
b) int arr = new int(5);
c) int arr[5];
d) int arr = new int[];
Answer: a) int[] arr = new int[5];
14. What is the use of the break keyword?
a) To end a loop
b) To skip an iteration
c) To exit a method
d) None of the above
Answer: a) To end a loop
15. How is memory allocated for an object in Java?
a) Heap
b) Stack
c) Both Heap and Stack
d) Register
Answer: a) Heap
Post-Test
1. What does public static void main(String[] args) signify in Java?
a) A special method to run the program
b) The method to define class members
c) A constructor
d) None of the above
Answer: a) A special method to run the program
2. Which of these is a checked exception in Java?
a) NullPointerException
b) IOException
c) ArithmeticException
d) IndexOutOfBoundsException
Answer: b) IOException
3. What does equalsIgnoreCase() do?
a) Compares two strings while ignoring case
b) Compares two objects ignoring case
c) Converts string to lowercase
d) None of the above
Answer: a) Compares two strings while ignoring case
4. What is the significance of super keyword?
a) Refers to parent class members
b) Refers to child class members
c) Creates a new instance
d) None of the above
Answer: a) Refers to parent class members
5. Which collection ensures no duplicate elements and maintains natural ordering?
a) HashSet
b) LinkedList
c) TreeSet
d) ArrayList
Answer: c) TreeSet
6. What will be the output of the following code?
int[] arr = {1, 2, 3};
[Link](arr[3]);
a) 0
b) IndexOutOfBoundsException
c) null
d) undefined
Answer: b) IndexOutOfBoundsException
7. Which method is used to convert a String to an int in Java?
a) toInt()
b) [Link]()
c) convert()
d) [Link]()
Answer: b) [Link]()
8. What is the output of the following program?
String s1 = "hello";
String s2 = "hello";
[Link](s1 == s2);
a) true
b) false
c) Error
d) undefined
Answer: a) true
9. What is the output of the following code?
try {
int a = 5 / 0;
} catch (ArithmeticException e) {
[Link]("Exception caught");
}
a) Exception caught
b) Error
c) RuntimeException
d) undefined
Answer: a) Exception caught
10. What is the result of the following code snippet?
String str1 = "abc";
String str2 = new String("abc");
[Link](str1 == str2);
a) true
b) false
c) Error
d) Undefined
Answer: b) false
11. Which keyword in Java is used to declare an abstract method?
a) abstract
b) interface
c) final
d) static
Answer: a) abstract
12. What will the following code output?
int x = 5;
x += 3;
[Link](x);
a) 5
b) 3
c) 8
d) Error
Answer: c) 8
13. Which method is called automatically during object creation?
a) init()
b) constructor
c) new()
d) start()
Answer: b) constructor
14. What happens when a main() method is declared as private?
a) The program compiles and runs successfully.
b) The program compiles but does not run.
c) Compilation error.
d) Runtime error.
Answer: b) The program compiles but does not run.
15. What is the output of the following program?
int x = 5;
[Link](++x);
a) 5
b) 6
c) Error
d) Undefined
Answer: b) 6
Angular
Pre-test
1. What is Angular primarily used for?
A. Server-side programming
B. Mobile app development
C. Building web applications
D. Database management
Answer: C
2. Which language is primarily used in Angular development?
A. JavaScript
B. Python
C. TypeScript
D. PHP
Answer: C
3. What does the @Component decorator do in Angular?
A. Defines a module
B. Defines a service
C. Defines metadata for a component
D. Creates a directive
Answer: C
4. Which of the following is NOT a type of data binding in Angular?
A. Two-way binding
B. Event binding
C. Database binding
D. Property binding
Answer: C
5. What is the purpose of Angular CLI?
A. Manage HTTP requests
B. Simplify Angular application development
C. Interact with the database
D. Debug Angular applications
Answer: B
6. Which file is responsible for bootstrapping the Angular application?
A. [Link]
B. [Link]
C. [Link]
D. [Link]
Answer: B
7. Which command is used to create a new Angular component using CLI?
A. ng generate component
B. ng create component
C. ng build component
D. ng add component
Answer: A
8. Which of these is an Angular lifecycle hook?
A. ngClick
B. ngOnInit
C. ngStart
D. ngStyle
Answer: B
9. What is the default port used by the Angular development server?
A. 3000
B. 4200
C. 8080
D. 5000
Answer: B
10. What is the purpose of HttpClient in Angular?
A. To make HTTP requests
B. To store cookies
C. To handle authentication
D. To build components
Answer: A
11. What is the primary purpose of Angular services?
A. Create UI components
B. Share data and logic across components
C. Perform CSS styling
D. Manage component lifecycle hooks
Answer: B
12. Which module is required for template-driven forms?
A. ReactiveFormsModule
B. FormsModule
C. HttpClientModule
D. BrowserModule
Answer: B
13. What is a feature of Angular Router?
A. Server-side rendering
B. Lazy loading of modules
C. Two-way data binding
D. None of the above
Answer: B
14. What is the purpose of the ngModel directive?
A. Event binding
B. Two-way data binding
C. Structural directives
D. None of the above
Answer: B
15. What is lazy loading in Angular?
A. Loading components without CSS
B. Loading routes on demand
C. Loading all modules upfront
D. Loading templates asynchronously
Answer: B
Post test
1. Which of the following is an Angular structural directive?
A. ngIf
B. ngModel
C. ngClass
D. ngStyle
Answer: A
2. How do you apply two-way data binding in Angular?
A. {{}}
B. []
C. [()]
D. {}
Answer: C
3. What does the [Link]() method do?
A. Initializes routing for child modules
B. Configures the root routing module
C. Creates a service
D. None of the above
Answer: B
4. What is used to define a route in Angular?
A. RouteConfig
B. RouterLink
C. Routes
D. Router
Answer: C
5. Which of the following is NOT a valid Angular directive?
A. ngClass
B. ngIf
C. ngForEach
D. ngStyle
Answer: C
6. What does the ngFor directive do?
A. Applies conditional rendering
B. Iterates over a collection to create elements
C. Adds styles to elements
D. Creates a form group
Answer: B
7. What is a pipe in Angular?
A. A directive for styling
B. A service for making HTTP requests
C. A function for transforming data in templates
D. A tool for creating components
Answer: C
8. What is the purpose of the @Input decorator?
A. Bind output events from a child component
B. Bind data from parent to child components
C. Define a service
D. Create a component
Answer: B
9. Which decorator is used to create a custom pipe?
A. @Pipe
B. @Injectable
C. @Directive
D. @Component
Answer: A
10. What is FormBuilder used for in Angular?
A. To simplify creating reactive forms
B. To create template-driven forms
C. To build HTTP requests
D. To generate components
Answer: A
11. Which Angular module is necessary for reactive forms?
A. FormsModule
B. ReactiveFormsModule
C. BrowserModule
D. HttpClientModule
Answer: B
12. What does the RouterOutlet directive do?
A. Defines a placeholder for dynamically loaded components based on routing
B. Applies CSS classes dynamically
C. Handles HTTP communication
D. Passes input to child components
Answer: A
13. Which of the following is NOT an Angular structural directive?
A. ngIf
B. ngClass
C. ngFor
D. ngSwitch
Answer: B
14. What is the difference between RouterLink and href in Angular?
A. RouterLink works with server-side navigation, while href works with client-side
routing
B. RouterLink enables navigation within the Angular app, while href reloads the page
C. RouterLink is used in directives, while href is used in services
D. Both are the same in Angular
Answer: B
15. What is the purpose of Angular's HostListener decorator?
A. Bind a method to an event on the host element
B. Define a directive for the host component
C. Modify the host's lifecycle hooks
D. Pass inputs to a host component
Answer: A
SpringBoot
Pre-Test
1. What does the @RestController annotation do?
A. Scans for beans in the project
B. Converts a class into a RESTful controller
C. Maps a request to a method
D. Disables auto-configuration
Answer: B
2. What HTTP method is typically used to fetch data in REST APIs?
A. POST
B. GET
C. PUT
D. DELETE
Answer: B
3. What is the purpose of @RequestMapping?
A. It maps web requests to specific handler methods
B. It validates incoming JSON data
C. It secures the application
D. It binds form data to objects
Answer: A
4. What does the @RequestParam annotation do?
A. Maps query parameters to method arguments
B. Maps headers to method arguments
C. Configures database parameters
D. Handles JSON request bodies
Answer: A
5. What is a common tool for testing REST APIs?
A. JUnit
B. Postman
C. Jenkins
D. Hibernate
Answer: B
6. What does the HTTP status code 201 indicate?
A. OK
B. Bad Request
C. Created
D. Not Found
Answer: C
7. How do you specify the base path for a Spring Boot REST API?
A. Using @RestPath
B. Configuring [Link]-path
C. Configuring [Link]
D. Using @RequestMapping on the controller class
Answer: D
8. How can you enable Cross-Origin Resource Sharing (CORS) in Spring Boot?
A. Using @EnableCors
B. Using @CrossOrigin
C. Configuring [Link]
D. Using @RequestParam
Answer: B
9. Which annotation is used to validate data in Spring Boot?
A. @Validate
B. @Valid
C. @CheckData
D. @Verify
Answer: B
10. What is the default port for a Spring Boot application?
A. 7070
B. 8080
C. 80
D. 9090
Answer: B
11. What is the main advantage of using Spring Boot?
A. Eliminates the need for XML configuration
B. Provides server hosting
C. Replaces Spring Framework
D. Removes the need for testing
Answer: A
12. Which annotation enables auto-configuration in Spring Boot?
A. @ComponentScan
B. @Configuration
C. @EnableAutoConfiguration
D. @Bean
Answer: C
13. What is the default port for a Spring Boot application?
A. 7070
B. 8080
C. 80
D. 9090
Answer: B
14. Which annotation is used to define a service class in Spring?
A. @Service
B. @Repository
C. @Component
D. @Configuration
Answer: A
15. Which of the following is a REST API constraint?
A. Stateful interactions
B. Client-server architecture
C. Single-layer architecture
D. Long-lived connections
Answer: B
Post Test
1. Which annotation is used to define the main configuration class in Spring Boot?
A. @Controller
B. @RestController
C. @SpringBootApplication
D. @Configuration
Answer: C
2. What is the default embedded server in Spring Boot?
A. Apache Tomcat
B. Jetty
C. Undertow
D. JBoss
Answer: A
3. What is the primary build tool used in most Spring Boot applications?
A. Ant
B. Maven/Gradle
C. Makefile
D. Jenkins
Answer: B
4. In the [Link] file, which property sets the server's port?
A. [Link]
B. [Link]
C. [Link]
D. [Link]
Answer: B
5. Which annotation is used to define a RESTful controller in Spring Boot?
A. @Controller
B. @RestController
C. @RequestMapping
D. @Service
Answer: B
6. What HTTP method is commonly used to create resources in a REST API?
A. GET
B. POST
C. PUT
D. DELETE
Answer: B
7. Which content type is typically used in RESTful APIs for data exchange?
A. text/html
B. application/json
C. application/xml
D. text/plain
Answer: B
5. How do you specify a path variable in a Spring Boot controller?
A. @RequestParam
B. @PathVariable
C. @PathParam
D. @QueryParam
Answer: B
6. What is the purpose of @CrossOrigin in Spring Boot?
A. Handle HTTP methods
B. Allow cross-origin resource sharing
C. Manage transactions
D. Enforce security
Answer: B
7. What annotation is used to map an entity to a database table in Spring Data JPA?
A. @Entity
B. @Table
C. @Repository
D. @Model
Answer: A
8. What method in JPARepository fetches all entities from the database?
A. findAll()
B. getAll()
C. selectAll()
D. fetchAll()
Answer: A
9. Which dependency is required for securing REST APIs in Spring Boot?
A. spring-boot-starter-web
B. spring-boot-starter-security
C. spring-boot-starter-data-jpa
D. spring-boot-starter-test
Answer: B
10. Which annotation is used to test a Spring Boot REST API?
A. @Test
B. @WebMvcTest
C. @RunWith
D. @ControllerTest
Answer: B
11. Which annotation is used to bind request body data in a REST API?
A. @PathVariable
B. @RequestParam
C. @RequestBody
D. @ResponseBody
Answer: C
12. What is the default HTTP message converter in Spring Boot?
A. Gson
B. Jackson
C. JSON-B
D. JAXB
Answer: B
13. How do you handle exceptions globally in Spring Boot?
A. @Controller
B. @RestControllerAdvice
C. @ExceptionHandler
D. @ErrorHandler
Answer: B
14. What does the @Transactional annotation do?
A. Opens a transaction at method level
B. Executes methods in parallel
C. Handles HTTP sessions
D. Manages REST API requests
Answer: A
15. What does @PathVariable annotation do?
A. Maps URL path segments to method parameters
B. Maps query parameters to objects
C. Validates incoming data
D. Secures the URL path
Answer: A