How can you access request parameters in a Spring MVC controller method?
1.By using the @RequestParam annotation.
2. By accessing them directly from the HttpServletRequest object.
3.By using the @PathVariable annotation.
4. By using the @RequestHeader annotation.
How can you define custom database queries in Spring Data JPA?
1.Using XML configuration files.
2.Using SQL scripts executed during application startup.
3.Using the @Query annotation and JPQL or native SQL queries.
4.Using external SQL files loaded at runtime.
In JPA, which strategy generates a primary key assigned by the database?
1.GenerationType.AUTO
2.GenerationType.SEQUENCE
3.GenerationType.IDENTITY
4.GenerationType.TABLE
In Spring MVC, what is the role of the ViewResolver?
1.Resolving bean dependencies
2.Handling exceptions
3.Resolving views to specific URLs
4.Handling request parameters
What does the @ResponseBody annotation do?
1.It sends the return value of a method back to the web response body.
2. It binds the parameters of a method to the request body.
3.It triggers an exception handling method.
4. It binds the result of a method to a view.
What does the @Valid annotation in Spring MVC do?
1.It ensures that the method is correctly overridden from a superclass.
2. It triggers validation of a method parameter or field.
3. It ensures that an HTTP request is valid.
4.It validates the return type of a method.
Which annotation is used to autowire a repository into a Spring component?
1.InjectRepository
2.AutoInject
3.Autowire
4.Resource
Choose the correct Query Method:
1.findByFirstNameOrLastName(String firstName, String lastName)
2. findByFirstNameAndLastName(String firstName, String lastName)
3.findByFirstNameOrLastName(Student student)
4.findByFirstNameLastName(String firstName, String lastName)
How can you control transaction management in Spring Data JPA?
1.By using the @Transactional annotation.
2. By configuring the transaction properties in the application.properties file.
3.By extending the JpaTransactionManager class.
4.By adding the @EnableTransactionManagement annotation to the configuration class
How can you customize the column name for a field in a JPA entity?
1.Column(name="custom_name")
2.FieldName("custom_name")
3.TableColumn("custom_name")
4.DatabaseColumn("custom_name")
How can you define a derived query in Spring Data JPA?
1.By annotating a method with @Query
2. By creating a method in the repository with a specific naming convention
3. By using the @DerivedQuery annotation
4.By creating an XML configuration
How can you handle exceptions in Spring MVC?
1.@ExceptionHandler
2.@CatchException
3.@ErrorResolver
4.@ResolveError
How can you indicate a Many-To-One relationship in JPA?
1.ManyToOne
2.OneToMany
3.ManyToMany
4.OneToOne
How can you mark a field as the primary key in a JPA entity?
1.PrimaryKey
2.EntityKey
3.Id
4.Key
How can you perform pagination in Spring Data JPA?
1.Using the @Pageable annotation
2.Using the Page and Pageable interfaces
3.Using the @Pagination annotation
4.Using the Paginator class
How do you execute a native query in Spring Data JPA?
1.Native
2.SQL
3.Execute
4.Query(nativeQuery = true)
How do you redirect to another URL in Spring MVC?
1."redirect:/url_path"
2."forward:/url_path"
3.goto:/url_path"
4.move:/url_path"
How do you specify that a controller method should produce JSON as a response?
1. @Produces("application/json")
2.@ResponseBody(type="json")
3.@ResponseFormat("JSON")
4.@RequestMapping(produces="application/json")
In a Spring Data JPA repository, how can you indicate a method should delete by a specific field?
1.deleteByFieldName
2.removeByFieldName
3.eraseByFieldName
4.exterminateByFieldName
In which layer is Spring MVC used?
1.Data layer
2.Business layer
3.Presentation layer
4.Integration layer
What does MVC stand for in Spring MVC?
1.Multi-View Controller
2.Module-View-Controller
3.Model-View-Controller
4.Model-Value-Configuration
What is Spring MVC
1.A programming language for web development.
2. A lightweight Java framework for building web applications.
3.A database management system for web applications.
4.A library for handling server-side rendering.
What is the aim of Spring Data JPA?
1.Spring Data JPA aims to reduce the amount of boilerplate code required for common database operations.
2.Spring Data JPA aims to provide the implementation for JPA interfaces
3.Spring Data JPA is a JPA provider and implementation for JPA interfaces
4.Spring Data JPA is an ORM framework that provides an implementation for JPA interfaces
What is the default implementation class of the JpaRepository interface?
1.JpaRepositoryImpl class
2.SimpleJpaRepository class
3.DeafultJpaRepository class
4.SimpleCrudRepository class
What is the purpose of the @GeneratedValue annotation in Spring Data JPA?
1.To specify the table name for entity mapping.
2.To define the primary key column in an entity.
3.To configure the fetching strategy for related entities.
4.To automatically generate primary key values for entities.
What is the purpose of the ModelAndView object in Spring MVC?
1.To store and pass data between the controller and the view.
2.To define the layout and styling of the web application.
3.To handle user authentication and authorization.
4.To manage the application's data access layer.
Which annotation binds a method parameter to a named attribute?
1.@ModelAttribute
2.@ParameterAttribute
3.@BindAttribute
4.@RequestValue
Which annotation in JPA allows you to embed another object as part of your entity?
1.Embeddable
2.Embedded
3.Include
4.PartOf
Which annotation in JPA allows you to embed another object as part of your entity?
1.Embeddable
2.Embedded
3.Include
4.PartOf
Which annotation indicates a method should handle HTTP POST requests?
1.@HttpPost
2.@PostHandler
3.@RequestMapping(method = RequestMethod.POST)
4.@PostMapping
Which annotation is commonly used to mark a repository interface in Spring Data JPA?
1.Service
2.Component
3.Controller
4.Repository
Which annotation is used to bind a method parameter to a web request header?
1.@RequestHeader
2.@Header
3.@BindHeader
4.@HTTPHeader
Which annotation is used to create a Named JPQL query?
1.NamedQuery
2.NamedJPQLQuery
3.NamedNativeQuery
4.SQLQuery
Which annotation is used to create a Spring MVC controller class?
1.@ControllerBean
2.@SpringController
3.@WebController
4.@Controller
Which annotation is used to denote a regular expression in URI template in Spring MVC?
1.@Regex
2.@PathVariable
3.@URIExpression
4.@MatchPattern
Which annotation is used to specify a custom query in Spring Data JPA?
1.CustomQuery
2.JPAQuery
3.Query
4.ExecuteQuery
Which annotation marks a class as an entity in JPA?
1.EntityClass
2.JPAEntity
3.Entity
4.TableEntity
Which dependency is required to use Spring Data JPA in a Spring Boot application?
1.spring-boot-starter-data-jpa
2.spring-boot-starter-web
3.spring-boot-starter-test
4.spring-boot-starter-security
Which interface do we extend to create a repository in Spring Data JPA?
1.Repository
2.JpaRepository
3.JpaRepository
4.SpringRepository
Which is the default JPA provider the Spring Data JPA internally uses?
1.EclipseLink
2.MyBatis
3.TopLink
4.Hibernate
Which of the following annotations is used to handle multipart file uploads?
1.@FileUpload
2.@MultipartFile
3.@RequestFile
4.@UploadPart
Which of the following components decides which controller method is to be called for a request?
1.DispatcherServlet
2.Controller
3.HandlerMapping
4.ViewResolver
Which of the following denotes a derived delete query in Spring Data JPA?
1.deleteByFieldName
2.findByFieldName
3.queryByFieldName
4.readByFieldName
Which of the following handles the HTTP request in Spring MVC?
1.DispatcherServlet
2.HandlerInterceptor
3.HttpListener
4.RequestHandler
Which of the following is NOT a fetch type in JPA?
1.EAGER
2.LAZY
3.IMMEDIATE
4.BOTH
Which of the following is NOT a valid Cascade type in JPA?C
1.PERSIST
2.REMOVE
3.MERGE
4.UPDATE
Which of the following represents a form-backing bean in Spring MVC?
1.@FormEntity
2.@ModelEntity
3.@ModelAttribute
4.@BeanForm
Which Spring annotation is used to handle Cross-Origin Resource Sharing (CORS) in Spring MVC?
1.CrossOrigin
2.CORSHandler
3.EnableCORS
4.CORSConfig
Which Spring Boot Starter would you use for developing web applications?
1.spring-boot-starter-web
2. spring-boot-starter-jdbc
3.spring-boot-starter-data
4. spring-boot-starter-app
Which Spring MVC module provides integration with RESTful services?
1.Spring RestController
2. Spring REST
3.Spring Web MVC
4. Spring WebFlux