Web, Jpa and SPRING MCQ
Web, Jpa and SPRING MCQ
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
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
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
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
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