0% found this document useful (0 votes)
70 views6 pages

Web, Jpa and SPRING MCQ

The document consists of a series of multiple-choice questions related to Spring framework, JPA, and Spring Boot. It covers topics such as annotations, lifecycle states, bean management, and RESTful web services. Each question provides four options, testing knowledge on various aspects of Spring and its components.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Web, Jpa and SPRING MCQ

The document consists of a series of multiple-choice questions related to Spring framework, JPA, and Spring Boot. It covers topics such as annotations, lifecycle states, bean management, and RESTful web services. Each question provides four options, testing knowledge on various aspects of Spring and its components.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1) Which interface of Spring represents the Spring container?

a. Context
b. ApplicationContext
c. Application
d. ServletContext
2) Which annotation is used to demarcate transactions in Spring?
a. @TransactionAttribute
b. @Transaction
c. @Demarcate
d. @Transactional

3) Which annotation is used by Spring to indicate that a bean plays the role of a DAO?
a. @DAO
b. @DataAccess
c. @Repository
d. @Service
4) Which annotation should be used on factory method which returns a bean to specify that the
spring container has to manage the programmatically created bean?
a. @Bean
b. @Component
c. @Configuration
d. @Autowired
5) Which annotation is used to create Pk-Fk relation b/w two tables?
a. JoinColumn
b. ForeignKey
c. JoinedKey
d. None of these

6) In which life cycle state, the JPA entity class is synchronized with the database? Please
choose only one answer:
a. New
b. Managed/Persistent
c. Synchronized
d. Detached
e. Removed

7) Which among the listed JPA annotations is used to mark the field as non-persistent?
a) @Temporal
b) @Transient
c) @NonPersist
d) @Version

8) Which association mapping need @JoinTable annotation?


a) OneToMany
b) ManyToOne
c) OneToOne
d) ManyToMany

9) Which of the following annotations are compulsorily required for entity classes while
using JPA?
a) @Mapped
b) @Persist
c) @Entity
d) @Table
e) @Id

10) Which attribute of @OneToMany is used to mark an entity as owned/non-owner/inverse


side?
a) cascade
b) mappedBy
c) ownedBy
d) propertyRef

11) Which of the statements listed below is false about JPQL?


a) JPQL is case sensitive while referring class name and its attributes
b) JPQL is polymorphic
c) JPQL uses table names and columns of table for queries
d) JPQL can be used to fetch scalar values [ only few columns/ attributes]

12) What is the scope of beans defined by Spring framework?


a. Prototype
b. Singleton
c. Request
d. Session

13) Which annotation is used to solve if more than one instance of interface exists while
injecting using @Autowired.
a) @Name
b) @Inject
c) @Qualifier
d) @Wired

14) Which HTTP header is used to identify the type of representation to be sent to client
a. Content-type
b. Accept
c. Payload
d. Data

15) Which of the following is a FrontController while using Spring MVC Framework?
a. ServletContainer
b. FrontController
c. DispatcherServlet
d. RestController

16) Which annotation is used to map URI to a resource in Spring Restful Webservices?
a. @Path
b. @RequestMapping
c. @Mapping
d. @Uri

17) Given a URI as http://amazon.com/mobiles/3 how do you read the value “3” in Spring
REST Controller
a. @RequestParam
b. @PathVariable
c. @RequestBody
d. @PathParam

18) What is Spring Boot Actuator?


a. It provides security
b. It provides Hypermedia
c. It provides metrics
d. It provides JMS connectivity

19) Which Filter is provided by Spring Security to bridge between ServletContainer and Spring’s
ApplicationContext?
a. SpringSecurityFilterChain
b. DelegatingFilterProxy
c. DispatcherServlet
d. UsernamePasswordAuthenticationFilter
20) Which annotation tells a controller that the JSON sent as payload should be de-serialized into Java
Object?
a. @JsonSerialize
b. @RequestMapping
c. @RequestBody
d. @GetMapping()
e. @RequestParam
21) While using Spring boot the property is injected using @Value annotation, like @Value( "${jdbc.url}" )
and the property is given as program argument and also defined in application.properties, which
value is assigned to the variable which has @Value annotation?
a. Property from application.properties
b. Property from program arguments
c. Error because the same property is available in both
d. Null
22) Which annotation can be used to provide a way to segregate parts of your application
configuration and make it only available in certain environments.
a. @Primary
b. @Qualifier
c. @Profile
d. @Environment
23) Which interface can be used to indicate that a bean should run when it is contained within a
SpringApplication.
a. CommandLineRunner
b. JpaRepository
c. ApplicationContext
d. SpringBootApplication

24) Which annotation is required while writing @Query in JpaRepository if the query has Update
JPQL statement
a. @Update
b. @Mutate
c. @Modifying
d. @Transactional
25) Which of the following is used to include links to the REST client in the returned response?
a. SWAGGER
b. ACTUATOR
c. PROMETHEUS
d. HATEOAS
26) While using JWT, which part of JWT does it have claims?
a. HEADER
b. PAYLOAD
c. SIGNATURE
d. NONE
27) Which annotation has to be used on top of method returning object which needs to be
managed by Spring container
a. @Component
b. @Bean
c. @Inject
d. @Autowired
28) Which keyword has to be used for creating DTOs which are immutable and used for class declaration
aimed at reducing the boilerplate code while using DTOs
a. record
b. sealed
c. @Data
d. @Value
29) A user can enter a number from text filed on an HTML form. Which of the following methods
can be used to retrieve the number?
A. getParameter()
B. getNumber()
C. getNumeric()
D. getValue ()

30) If HttpSession API is used for session tracking which method can be used to terminate the
session?
A. close( )
B. removeSession( )
C. setSession(null)
D. invalidate( )
31) Smitha has written the following code for a servlet and deploys the same. What will be the
output when the servlet is invoked? [Assume all the classes are properly imported]
@WebServlet(“/hello”)
public class Hello extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html>");
System.out.println("Welcome");
out.println("</html>");
}
}
a) It will generate an exception
b) There will be no output in the browser
c) It will print "Welcome" in the browser

32) Select which of the following statement is true if we store an attribute in the request scope and
want to retrieve the same attribute from another Dynamic resource:
a) do a sendRedirect()
b) do a requestDispatcher.forward(request, response)
c) I will get the attribute with both.
d) We can’t store data in request scope

33) Suppose we have created a thread-pool by name “FLIGHTS-POOL” using factory


method in Spring. How do you specify that a particular method should use the given pool.

a) place @EnableAsync on top of the method

b) place @Async(“FLIGHTS-POOL”) on top the method

c) place @Concurrency(“FLIGHTS-POOL”) on top of the method


d) we need to programmatically select a thread pool.

34) While building web applications which of the following needs to be used for performing
cross-cutting concerns like logging, security, encryption, profiling, etc.

a) Filter

b) Servlet

c) JSP

d) Listener

35) In Spring AOP, what defines a point where an advice should be executed?

a) Aspect

b) JoinPoint

c) Pointcut

d) Advice

You might also like