
Q91
Q91 A global exception handler defined with @ControllerAdvice is not handling exceptions. What could be the possible reason?
The class is not annotated with @RestController
The method is missing @ExceptionHandler
The class is not detected by component scanning
Both B and C
Q92
Q92 What is the primary purpose of Spring Security in a Spring MVC application?
To manage database connections
To handle dependency injection
To provide authentication and authorization
To optimize performance
Q93
Q93 Which component in Spring Security is responsible for authenticating users?
AuthenticationManager
AuthorizationFilter
SecurityContextHolder
WebSecurityConfigurer
Q94
Q94 What does the SecurityContextHolder in Spring Security do?
Stores security-related information for a request
Manages database transactions
Handles session timeouts
Acts as a view resolver
Q95
Q95 Which of the following best describes method-level security in Spring Security?
It restricts access at the service layer
It applies security at the controller level
It ensures only GET requests are allowed
It manages CSRF protection
Q96
Q96 Which annotation enables Spring Security in a Spring Boot application?
@EnableWebSecurity
@EnableSecurity
@EnableAuthentication
@EnableSpringSecurity
Q97
Q97 Which method is used to configure HTTP security in Spring Security?
configure(HttpSecurity http)
setSecurity(HttpSecurity http)
defineSecurity(HttpSecurity http)
enableSecurity(HttpSecurity http)
Q98
Q98 How do you define a custom authentication provider in Spring Security?
Implement AuthenticationProvider
Extend WebSecurityConfigurerAdapter
Use @EnableWebSecurity
Define a custom filter
Q99
Q99 How can you disable CSRF protection in Spring Security?
csrf().disable()
disableCsrf()
setCsrf(false)
ignoreCsrf()
Q100
Q100 A user is unable to log in to a secured Spring MVC application. What is the most likely cause?
The user does not exist in the database
The SecurityContextHolder is null
The session has expired
The database connection is slow
Q101
Q101 A developer is getting a 403 Forbidden error when accessing a secured endpoint. What could be the reason?
The user is not authenticated
The user does not have the required role
Spring Security is disabled
The endpoint URL is incorrect
Q102
Q102 A Spring MVC application is redirecting users to the login page repeatedly. What could be the cause?
The session is expiring too quickly
The authentication filter is misconfigured
CSRF protection is disabled
The database is down
Q103
Q103 What does REST stand for in RESTful web services?
Representational State Transfer
Remote Execution of Services and Transactions
Reliable Event Synchronized Transactions
Resource Exchange and State Transfer
Q104
Q104 Which annotation is used to create a RESTful controller in Spring MVC?
@RestController
@Controller
@RequestMapping
@ResponseBody
Q105
Q105 What is the main difference between @Controller and @RestController in Spring MVC?
@RestController returns JSON/XML responses, while @Controller returns views
@Controller is for REST APIs, while @RestController is for JSPs
@RestController does not require @RequestMapping
@Controller automatically enables security
Q106
Q106 Which HTTP method is typically used to update an existing resource in a RESTful API?
GET
POST
PUT
DELETE
Q107
Q107 Which annotation maps a method to an HTTP GET request in Spring MVC?
@PostMapping
@GetMapping
@PutMapping
@DeleteMapping
Q108
Q108 How can you return JSON responses from a Spring MVC RESTful API?
Use @RestController and return Java objects
Manually serialize Java objects to JSON
Use @Controller with @ResponseBody
Use @RequestMapping
Q109
Q109 Which annotation is used to extract path variables in a Spring MVC RESTful API?
@RequestParam
@PathVariable
@ModelAttribute
@RequestBody
Q110
Q110 A RESTful API in Spring MVC is returning a 415 Unsupported Media Type error. What could be the reason?
The request does not specify the correct Content-Type header
The URL mapping is incorrect
The service is down
The database is not connected
Q111
Q111 A client is getting a 404 Not Found error when calling a REST API endpoint. What could be the issue?
The method is private
The URL does not match any controller mapping
The request body is missing
The response type is incorrect
Q112
Q112 Which interface in Spring JDBC provides methods for executing SQL queries?
JdbcTemplate
EntityManager
SessionFactory
DataSource
Q113
Q113 What is the primary advantage of using JPA over JDBC?
JPA allows object-relational mapping
JPA does not require SQL knowledge
JPA is faster than JDBC
JPA does not need a database connection
Q114
Q114 Which of the following is NOT a key feature of Spring JDBC?
Simplified error handling
Automatic transaction management
Object-relational mapping
PreparedStatement support
Q115
Q115 Which annotation is used to mark an entity class in JPA?
@Table
@Entity
@Repository
@PersistenceContext
Q116
Q116 Which annotation is used to define a primary key in a JPA entity?
@Column
@PrimaryKey
@Id
@Key
Q117
Q117 How do you configure a DataSource bean in a Spring application using Java-based configuration?
Use @DataSourceConfig annotation
Manually create a DataSource object and annotate it with @Bean
Use @Autowired on a DataSource field
Define it in application.properties
Q118
Q118 Which method is used in JdbcTemplate to execute an INSERT query?
queryForObject()
update()
executeQuery()
persist()
Q119
Q119 A developer is facing a 'No qualifying bean of type DataSource' error. What could be the cause?
The DataSource bean is not defined
The database is down
The table does not exist
The SQL syntax is incorrect
Q120
Q120 A JPA query is returning an empty result set despite data being present in the database. What could be the issue?
The entity class is not properly annotated
The database connection is closed
The application is using JDBC instead of JPA
The entity is not in the persistence context