0% found this document useful (0 votes)
190 views37 pages

CCEE Previous Year July and Dec 2023 QPapers

The document contains a detailed breakdown of questions and answers from the CCEE Question Paper for July 2023, focusing on topics such as Servlets & JSP, JDBC, and Hibernate & JPA. Each question is accompanied by a correct answer and an explanation of why other options are incorrect. The content is structured to aid understanding of key concepts and mechanisms in Java web development and database management.

Uploaded by

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

CCEE Previous Year July and Dec 2023 QPapers

The document contains a detailed breakdown of questions and answers from the CCEE Question Paper for July 2023, focusing on topics such as Servlets & JSP, JDBC, and Hibernate & JPA. Each question is accompanied by a correct answer and an explanation of why other options are incorrect. The content is structured to aid understanding of key concepts and mechanisms in Java web development and database management.

Uploaded by

Ashok Pate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CCEE Question Paper July 2023

Of course. Here is a detailed breakdown of each question from the provided images, organized
by topic. Each answer includes a clear explanation for all options.

Topic: Servlets & JSP

Question #1: How many ServletContext objects are available for an entire web
application?

●​ Correct Answer: Only one


●​ Explanation:
○​ One each per servlet: Incorrect. ServletConfig objects are one per servlet, not
ServletContext.
○​ One each per request: Incorrect. HttpServletRequest objects are one per
request.
○​ One each per response: Incorrect. HttpServletResponse objects are one per
response.
○​ Only one: Correct. The ServletContext represents the entire application. The
container creates exactly one instance per web application and shares it among
all servlets and JSPs.
●​

Question #8: How is the dynamic interception of requests and responses to transform
the information done?

●​ Correct Answer: servlet filter


●​ Explanation:
○​ servlet container: Incorrect. The container (e.g., Tomcat) manages the lifecycle
but doesn't implement interception logic itself.
○​ servlet config: Incorrect. This object holds initialization parameters for a specific
servlet.
○​ servlet context: Incorrect. This object represents the application scope.
○​ servlet filter: Correct. A Filter is designed specifically for the purpose of
intercepting requests and responses to perform cross-cutting tasks like logging,
authentication, or data transformation.
●​

Question #10: Any client request to access resources in the WEB-INF/ directory must be
returned with...

●​ Correct Answer: SC_NOT_FOUND

prajwalpawar
●​ Explanation:
○​ BAD_REQUEST: Incorrect. This is a 400 error, typically for malformed request
syntax.
○​ SC_NOT_FOUND: Correct. The WEB-INF directory is a private, secure area.
The server is required to act as if resources inside it do not exist when requested
directly by a client, hence a 404 Not Found error.
○​ SC_INTERNAL_SERVER_ERROR: Incorrect. This is a 500 error, indicating a
server-side code failure.
○​ ESC_BAD_REQUEST: Incorrect. This is not a standard HTTP status code
constant.
●​

Question #15: In Servlet 3.0 which of the given annotation is used to declare the
following class as a Servlet Component with the URL pattern will be "/hello"?

●​ Correct Answer: @WebServlet("/hello")


●​ Explanation:
○​ @WebServlet: Incorrect. This is the correct annotation, but it requires the URL
pattern to be specified.
○​ @Servlet("/hello"): Incorrect. The standard annotation is @WebServlet, not
@Servlet.
○​ @Servlet: Incorrect. This is not the correct annotation for this purpose.
○​ @WebServlet("/hello"): Correct. This is the standard annotation from the Servlet
3.0 API to declare a servlet and map it to a URL pattern, replacing the need for
web.xml.
●​

Question #16: Assume you have a servlet class... and needs to forward it to a servlet
accessible at the URL "processingservlet". Which step do you need to carry out before
you forward the request?

●​ Correct Answer: RequestDispatcher rd =


myReq.getRequestDispatcher("processingservlet");
●​ Explanation:
○​ HttpServletResponse resp = myReq.next(...): Incorrect. The HttpServletRequest
object has no next() method.
○​ RequestDispatcher rd = myReq.getRequestDispatcher(...): Correct. To forward a
request, you must first obtain a RequestDispatcher object from the current
request. The next step would be to call rd.forward().
○​ HttpServletRequest nextReq = myReq.next(...): Incorrect. The
HttpServletRequest object has no next() method.
○​ HttpServlet httpServ = myReq.next(...): Incorrect. The HttpServletRequest object
has no next() method.
●​

prajwalpawar
Question #18: Which of the following is not a valid attribute of the <jsp:useBean> Action
tag?

●​ Correct Answer: property


●​ Explanation:
○​ id: Correct attribute. Specifies the name of the variable that will reference the
bean.
○​ class: Correct attribute. Specifies the bean's class to instantiate if one is not
found.
○​ type: Correct attribute. Specifies the type of the variable referencing the bean.
○​ property: Incorrect attribute. The property attribute is used with
<jsp:setProperty> and <jsp:getProperty>, not <jsp:useBean>.
●​

Question #22: What is correct about JSP Scriptlets?

●​ Correct Answer: Instructions in a Scriptlet must follow Java syntax


●​ Explanation:
○​ A loop must start in one Scriptlet and end in it: Incorrect. While it is bad practice,
a loop can be opened in one scriptlet and closed in another, with HTML in
between.
○​ Instructions in a Scriptlet must follow Java syntax: Correct. A scriptlet (<% ...
%>) contains pure Java code that is inserted directly into the generated servlet's
_jspService method, so it must be valid Java.
○​ Semicolon is not required at the end of each statement...: Incorrect. Semicolons
are required for Java statements inside a scriptlet.
○​ All of the above: Incorrect.
●​

Question #26: Which of the following is the right sequence of stages in the JSP life
cycle?

●​ Correct Answer: Compilation, Initialization, Execution, Cleanup (This is the closest,


though incomplete)
●​ Explanation: The full lifecycle is: Translation (JSP to .java) -> Compilation (.java to
.class) -> Initialization (jspInit()) -> Execution (_jspService()) -> Destruction/Cleanup
(jspDestroy()).
○​ Initialization, Cleanup, Compilation, Execution: Incorrect order.
○​ Initialization, Compilation, Cleanup, Execution: Incorrect order.
○​ Compilation, Initialization, Execution, Cleanup: Best available option. It correctly
places the main stages in order, even though it omits the initial "Translation" step.
○​ Cleanup, Compilation, Initialization, Execution: Incorrect order.
●​

Question #30: The return type of getParameterNames() of HttpServletRequest object is:

prajwalpawar
●​ Correct Answer: java.util.Enumeration
●​ Explanation:
○​ Array of Strings: Incorrect.
○​ java.util.ArrayList: Incorrect. You would need to manually convert the result to an
ArrayList.
○​ java.util.Enumeration: Correct. This is a legacy part of the Servlet API. The
method returns an Enumeration of String objects.
○​ String: Incorrect. It returns a collection of names, not a single one.
●​

Question #34: When it comes to the Initialization phase of the JSP life cycle, which of the
following is true?

●​ Correct Answer: When a container loads a JSP it invokes the jspInit() method before
servicing any requests.
●​ Explanation:
○​ When a container loads a JSP it invokes the jspInit() method...: Correct. The
jspInit() method is called once after compilation but before the JSP handles its
first request. It's for one-time setup.
○​ Container invokes _jspService() method during Initialization phase: Incorrect.
_jspService() is called during the Execution (or Servicing) phase for every
request.
○​ Both of the above: Incorrect.
○​ None of the above: Incorrect.
●​

Question #40: Which of the following is not a valid JSP Action tag?

●​ Correct Answer: jsp:useProperty


●​ Explanation:
○​ jsp:plugin: Valid tag. Used to embed applets.
○​ jsp:include: Valid tag. Used to include another resource at request time.
○​ jsp:useProperty: Invalid tag. The valid tags are <jsp:setProperty> and
<jsp:getProperty>.
○​ jsp:useBean: Valid tag. Used to find or instantiate a JavaBean.
●​

Topic: JDBC

Question #3: Which of these JDBC mechanisms allows us to define checkpoints for a
transaction?

●​ Correct Answer: Savepoint

prajwalpawar
●​ Explanation:
○​ CheckPoint: Incorrect. This is a general database term for synchronizing data to
disk, not a JDBC transactional checkpoint.
○​ CommitPoint: Incorrect. This is not a standard JDBC term.
○​ Savepoint: Correct. A Savepoint is an object created within a transaction that
acts as a checkpoint to which you can later roll back, without nullifying the entire
transaction.
○​ RollbackPoint: Incorrect. This is not a standard JDBC term.
●​

Question #4: What are the correct declarations of getConnection() method in


DriverManager class?

●​ Correct Answer: All options except getConnection(String urls[]) are valid. The most
common is getConnection(String url, String user, String password).
●​ Explanation: The DriverManager class has several overloaded getConnection methods
to provide flexibility.
○​ getConnection(String url, Properties info): Valid.
○​ getConnection(String urls[]): Invalid. There is no such method in DriverManager.
○​ getConnection(String url, String user, String password): Valid and very common.
○​ getConnection(String url): Valid.
●​

Question #11: Identify which of the following types of JDBC drivers makes use of the
database native protocol.

●​ Correct Answer: Native-protocol, pure Java driver


●​ Explanation:
○​ JDBC-ODBC Bridge...: Incorrect. This is a Type 1 driver.
○​ Native-API, partly Java driver: Incorrect. This is a Type 2 driver.
○​ JDBC-Net, pure Java driver: Incorrect. This is a Type 3 driver, which uses a
generic network protocol to a middleware server.
○​ Native-protocol, pure Java driver: Correct. This describes the Type 4 driver,
which communicates directly with the database using its specific network
protocol.
●​

Question #12: Which of the following methods is best suited to call on a JDBC
connection object... where the same SQL statement needs to be executed frequently with
different parameters?

●​ Correct Answer: prepareStatement()


●​ Explanation:
○​ createStatement(): Incorrect. This is for static SQL and re-parses the query every
time.

prajwalpawar
○​ prepareStatement(): Correct. This is the exact purpose of PreparedStatement. It
pre-compiles the SQL for efficiency and uses ? placeholders for parameters,
preventing SQL injection.
○​ prepareCall(): Incorrect. This is specifically for calling stored procedures.
○​ nativeSQL(): Incorrect. This is for translating JDBC SQL into the database's
native SQL, not for execution.
●​

Question #28: Assume we do not explicitly set a value for auto-commit... what is the
outcome?

●​ Correct Answer: The rows are inserted and committed


●​ Explanation:
○​ An error is thrown as executeUpdate is not meant for inserts: Incorrect.
executeUpdate is used for INSERT, UPDATE, and DELETE.
○​ The rows are inserted, but not committed: Incorrect. This would happen only if
setAutoCommit(false) was called.
○​ The rows are inserted and committed: Correct. The default mode for a JDBC
Connection is auto-commit=true. Every statement is treated as its own
transaction and is committed immediately upon successful execution.
○​ An error is thrown since we need to explicitly set a value for auto-commit:
Incorrect. No explicit setting is required to use the default behavior.
●​

Topic: Hibernate & JPA

Question #6: What is TRUE about the cascading and cascade mode attributes in JPA
Entities?

●​ Correct Answer: Cascade mode attributes can be specified for the association
annotations (like @OneToMany) in an entity
●​ Explanation:
○​ Cascade mode attributes can be specified...: Correct. The cascade attribute
(e.g., cascade = CascadeType.ALL) is defined within relationship annotations like
@OneToMany.
○​ The cascading direction is from the target entity to the source entity: Incorrect. It's
from the source (parent) to the target (child).
○​ PERSIST, DELETE are the only valid cascading mode attributes: Incorrect.
MERGE, REFRESH, and ALL are also valid.
○​ Cascading is not supported in JPA: Incorrect. It is a fundamental feature.
●​

Question #13: Which level of cache is represented by the Hibernate Session object?

prajwalpawar
●​ Correct Answer: First Level Cache
●​ Explanation:
○​ First Level Cache: Correct. The Session is the first-level cache. It is scoped to
the session, mandatory, and enabled by default.
○​ Second Level Cache: Incorrect. This is an optional cache scoped to the
SessionFactory and shared across sessions.
○​ Query Cache: Incorrect. This is a separate, optional cache for storing the results
of queries.
○​ Database Cache: Incorrect. This refers to the database's own internal caching,
not Hibernate's.
●​

Question #17: Which of the following annotations is used in JPA to link two tables
through a relation table?

●​ Correct Answer: @JoinTable


●​ Explanation:
○​ @JoinTable: Correct. This annotation is used with @ManyToMany to define the
intermediate "join table" that links the two entity tables.
○​ @LinkTable, @RelationTable: Incorrect. These annotations do not exist in JPA.
○​ @JoinColumn: Incorrect. This is used to define a foreign key column in a single
table for @ManyToOne or @OneToOne relationships.
●​

Question #23: Which of the following annotations in JPA, is used to specify a primary key
- foreign key relation between two entities?

●​ Correct Answer: @JoinColumn


●​ Explanation:
○​ @JoinColumn: Correct. This annotation explicitly defines a column as a foreign
key that joins to another entity's primary key.
○​ @IdClass, @EmbeddedId: Incorrect. These are for defining composite primary
keys.
○​ @MapsId: Incorrect. This is a special-case annotation where a child's ID is also
its foreign key to the parent. @JoinColumn is the general-purpose answer.
●​

Question #24: Which of the following annotations is applied on the unique Id of an entity
to get its value generated?

●​ Correct Answer: @GeneratedValue


●​ Explanation:
○​ @Generator, @IdGenerator: Incorrect. These are not standard JPA annotations
for this purpose.

prajwalpawar
○​ @GeneratedValue: Correct. This annotation is used alongside @Id to specify
the strategy (e.g., IDENTITY, SEQUENCE) for automatically generating the
primary key value.
○​ @Sequence: Incorrect. This is used to define a database sequence, often in
conjunction with @GeneratedValue(strategy=SEQUENCE).
●​

Question #25: Which of the following statements is false about the Hibernate
SessionFactory?

●​ Correct Answer: It is a class


●​ Explanation:
○​ It is a class: False Statement (and therefore the correct answer).
SessionFactory is an interface (org.hibernate.SessionFactory). Hibernate
provides the concrete implementation.
○​ It is a factory of session objects: True statement. Its main purpose is to create
Session instances.
○​ It is a thread safe object: True statement. It's designed to be a singleton and
shared across the application.
○​ It represents second level cache: True statement. It holds the (optional)
second-level cache.
●​

Question #27: Choose the inheritance model, which is not available in Hibernate.

●​ Correct Answer: Table Per Object


●​ Explanation: Hibernate supports Table Per Subclass, Table Per Class Hierarchy, and
Table Per Concrete Class.
○​ Table Per Object: Not a standard Hibernate inheritance model.
●​

Question #33: Which of the following is not a disadvantage of Hibernate?

●​ Correct Answer: Hibernate provides automatic support for transactions


●​ Explanation:
○​ Hibernate may be slower than JDBC...: This can be a disadvantage if not
configured properly.
○​ Hibernates connection pool is not great: This is often cited as a disadvantage;
most production apps use a dedicated pool like HikariCP.
○​ Need to learn HQL syntax: This is a learning curve and can be seen as a
disadvantage.
○​ Hibernate provides automatic support for transactions: This is a major
advantage, not a disadvantage.
●​

prajwalpawar
Question #35: In hibernate, _________ annotation is used to represent a primary key.

●​ Correct Answer: @Id


●​ Explanation:
○​ @Id: Correct. This is the standard JPA annotation to mark a field as the primary
key.
○​ @GeneratedValue: Incorrect. This is used with @Id to specify generation
strategy.
○​ @Entity: Incorrect. This marks the entire class as an entity.
○​ @Key: Incorrect. This is not a standard JPA annotation for primary keys.
●​

Question #39: ...which of the following is not a valid value for the hibernate.hbm2ddl.auto
property?

●​ Correct Answer: drop


●​ Explanation: Valid values are create, create-drop, update, validate, and none.
○​ drop: Invalid. There is no standalone drop value.
●​

Topic: Spring & Spring Boot

Question #2: In a SpringBoot application the class which has the main method, should be
annotated with...

●​ Correct Answer: @SpringBootApplication


●​ Explanation:
○​ @EnableSpringApplication, @SpringApplication: Incorrect. These annotations do
not exist.
○​ @SpringBootApplication: Correct. This is the key convenience annotation that
enables auto-configuration, component scanning, and marks the class as a
configuration source.
○​ @EnableSpringBootApplication: Incorrect. This annotation does not exist.
●​

Question #7: Which of the following annotations can be used for testing a Spring Boot
application, which creates the entire context without starting the server?

●​ Correct Answer: @SpringBootTest


●​ Explanation:
○​ @Test: The standard JUnit test annotation, but it doesn't load a Spring context.
○​ @WebMvcTest: Loads only the web layer (controllers, etc.), not the entire
context.

prajwalpawar
○​ @SpringBootTest: Correct. This annotation loads the full application context. By
default (webEnvironment = MOCK), it does not start a real server.
○​ @SpringBootIntegrationTest: Incorrect. This annotation does not exist.
●​

Question #14: What dependency artifact Id must be added to see the secure actuators in
Spring Boot?

●​ Correct Answer: spring-boot-starter-security


●​ Explanation:
○​ spring-boot-secure-actuators: Incorrect. No such starter exists.
○​ spring-boot-start-web-services: Incorrect. This is for SOAP web services.
○​ spring-boot-dev-tools: Incorrect. This provides development-time conveniences
like live reload.
○​ spring-boot-starter-security: Correct. Adding Spring Security to the classpath is
what triggers the auto-configuration that secures the actuator endpoints.
●​

Question #20: Which of the following cannot be supplied as an automatic configuration


in Spring Boot?

●​ Correct Answer: Request Handler


●​ Explanation:
○​ Request Handler: Correct. A request handler is your custom business logic
inside a @Controller method. Spring Boot cannot automatically create this for
you.
○​ Dispatcher Servlet, View Resolver, Handler Mapping: Incorrect. Spring Boot's
auto-configuration is excellent at setting up these infrastructure beans for you.
●​

Question #21: Which of the following annotations is recommended for a partial update of
a resource in a Spring Boot REST controller?

●​ Correct Answer: @PatchMapping


●​ Explanation:
○​ @GetMapping: For retrieving data.
○​ @PostMapping: For creating a new resource.
○​ @PutMapping: For a full update/replacement of a resource.
○​ @PatchMapping: Correct. PATCH is the standard HTTP method for applying
partial modifications.
●​

Question #36: Complete the following aspect implementation for an around advice...

●​ Correct Answer: @Pointcut("execution(* com.demo.dao.*.*(..))") for Line 4 and


@Around("businessMethods()") for Line 7.

prajwalpawar
●​ Explanation: A @Pointcut defines a reusable expression that identifies join points
(method executions). The @Around advice then references this named pointcut to apply
its logic. The other options have the annotations reversed or use incorrect syntax
(expression(...)).

Question #37: Which of the following problems can be solved using Lookup Method
Injection in Spring?

●​ Correct Answer: Prototype to Singleton dependency


●​ Explanation:
○​ Singleton to Prototype dependency: Incorrect. This is the reverse of the problem.
○​ Prototype to Singleton dependency: Correct. Lookup Method Injection is the
solution for the specific problem where a long-lived singleton bean needs a fresh
instance of a short-lived prototype bean each time a method is called.
○​ Singleton to Singleton dependency: Standard dependency injection handles this.
○​ Prototype to Prototype dependency: Standard dependency injection handles this.
●​

Question #38: In Spring MVC _________ class works as the frontend controller.

●​ Correct Answer: DispatcherServlet


●​ Explanation:
○​ DispatcherServlet: Correct. This is the core front controller in Spring MVC.
○​ All Classes annotated with @Controller: Incorrect. These are the handlers
delegated to by the front controller.
○​ ViewResolver: Incorrect. This resolves view names to view files.
○​ HandlerMapping: Incorrect. This maps requests to controller methods.
●​

Topic: General Web Concepts (REST, Maven, etc.)

Question #5: The ability to invoke a RESTful method multiple times without changing the
state of the server on subsequent invocations is known as:

●​ Correct Answer: Idempotence


●​ Explanation:
○​ Idempotence: Correct. This is the definition. GET, PUT, DELETE are idempotent.
POST is not.
○​ Immutability: Incorrect. This refers to an object whose state cannot be changed
after creation.
○​ Statefulness: Incorrect. This is the opposite of the stateless principle of REST.
○​ Uniformity: Incorrect. This refers to the uniform interface constraint in REST.
●​

prajwalpawar
Question #9: What is a POM file in a Maven project?

●​ Correct Answer: A file that stores the structure and dependencies for your Maven
project
●​ Explanation:
○​ A file that contains the compiled bytecode...: Incorrect. This would be a .class file.
○​ A package that stores resources...: Incorrect. Resources are stored in directories
like src/main/resources.
○​ A file that points to the media resources...: Incorrect.
○​ A file that stores the structure and dependencies...: Correct. The pom.xml
(Project Object Model) is the central configuration file in Maven.
●​

Question #29: Which of the following is not a valid phase in the Maven default build
lifecycle?

●​ Correct Answer: The question is flawed. All listed are valid phases.
●​ Explanation: clean belongs to the clean lifecycle. validate, compile, and install belong to
the default lifecycle. All are valid Maven phases. If forced to choose the "odd one out",
clean is the most likely answer as it belongs to a different lifecycle than the others.

Question #31: How would you configure a RESTful URL parameter that supports a search
for a book based on its ID?

●​ Correct Answer: GET /books/{id}


●​ Explanation:
○​ GET /{id}/books/: Incorrect structure.
○​ GET /books/{id}: Correct. This uses a path variable {id} to identify a unique
resource within the /books collection, which is standard REST practice.
○​ GET /book?id={id}, GET /books?id={id}: Incorrect. Query parameters
(?key=value) are typically used for filtering or sorting a collection (e.g.,
/books?author=King), not for identifying a unique resource by its primary key.
●​

Question #32: Which of the following can be used to test APIs in a web service?

●​ Correct Answer: Writing Web application using RestTemplate


●​ Explanation:
○​ Postback tool: Incorrect. This term is more associated with older ASP.NET Web
Forms.
○​ Writing Web application using RestTemplate: Correct. RestTemplate is Spring's
primary tool for creating a client to consume RESTful services.
○​ Writing web application using RestManager: Incorrect. Not a standard tool/class.
○​ Writing web application using RestMan: Incorrect. Likely a typo for Postman,
which is a GUI tool, not a library for writing a web application.

prajwalpawar
CCEE Question Paper Dec 2023

Of course. Here is a detailed, topic-wise breakdown of all the questions from the new set of
images, with clear explanations for each option.

Topic: Servlets & JSP

Question #1 (Set 2): How can a constructor be used for a servlet?

●​ Correct Answer: Initialization


●​ Explanation:
○​ Initialization: Correct. While the primary initialization method is init(), the servlet
container first calls the servlet's constructor to create the instance before calling
init(). Therefore, the constructor is part of the initialization process.
○​ Constructor function: Vague and less precise than "Initialization."
○​ Initialization and Constructor function: Redundant.
○​ Setup() method: Incorrect. There is no standard setup() method in the servlet
lifecycle.
●​

Question #4 (Set 2): EL expression in JSP can be disabled by:

●​ Correct Answer: setting isELIgnored to TRUE


●​ Explanation:
○​ setting isELIgnored to TRUE: Correct. In the JSP page directive, <%@ page
isELIgnored="true" %> will disable Expression Language evaluation for that
page, causing ${...} to be treated as literal text.
○​ setting isELIgnored to FALSE: Incorrect. This is the default setting, which enables
EL.
○​ Cannot be disabled: Incorrect. It can be disabled.
○​ browser settings: Incorrect. This is a server-side configuration, not controlled by
the browser.
●​

Question #7 (Set 2): isErrorPage attribute is mandatory in the page directive of the JSP
which handles all the errors/exception generated:

●​ Correct Answer: true


●​ Explanation:
○​ true: Correct. To make the special exception implicit object available on a JSP
error page, you must declare <%@ page isErrorPage="true" %>. Without this,
the page is just a regular JSP and cannot access the exception details.

prajwalpawar
○​ false: Incorrect.
○​ No such attribute for page directive: Incorrect. The attribute exists and is crucial.
○​ No such page directive: Incorrect. The page directive is the most common JSP
directive.
●​

Question #8 (Set 2): Cookie is valid for a single session only.

●​ Correct Answer: Both B & C (Non-persistent and Persistent)


●​ Explanation: The premise of the question is flawed, as a cookie's lifetime is
independent of a session's lifetime.
○​ Validity of the cookie does not depend upon the session: This is the most
technically correct statement.
○​ Non-persistent: This describes a "session cookie" which is deleted when the
browser closes. It is one type of cookie.
○​ Persistent: This describes a cookie with an explicit expiration date set via
setMaxAge(), which survives browser restarts. It is another type of cookie.
○​ Both B & C: Correct answer in the context of the options. Since cookies can
be either non-persistent (like a session cookie) or persistent, both are valid types.
The initial statement "valid for single session only" is only true for non-persistent
cookies.
●​

Question #11 (Set 2): Given an HttpServletRequest... which code is more appropriate to
be inserted...?

●​ Correct Answer: session = request.getSession(false);


●​ Explanation: The code checks if session is null. The goal is to get an existing session
but not create a new one.
○​ session = response.getSession(): Incorrect. getSession() is a method of the
request object, not the response.
○​ session = request.getSession(): Incorrect. This is equivalent to getSession(true).
It will create a new session if one doesn't exist, which makes the if (session ==
null) check pointless.
○​ session = request.getSession(true): Incorrect. Same reason as above; it always
returns a session (either existing or new), so it can never be null.
○​ session = request.getSession(false): Correct. This method will return the existing
session if one exists, or null if one does not. This is exactly what is needed for the
subsequent null check to work correctly.
●​

Question #16 (Set 2): Which one is the correct order of phases in JSP life cycle?

●​ Correct Answer: Compilation, Initialization, Execution, Cleanup (This is the closest,


though incomplete)

prajwalpawar
●​ Explanation: As explained previously, the full cycle is Translation -> Compilation ->
Initialization -> Execution -> Cleanup.
○​ Compilation, Initialization, Execution, Cleanup: Best available option. It places
the main stages in the correct relative order.
●​

Question #28: The annotation used for declaring a servlet with multiple URL patterns
(e.g. /ABC, /XYZ) is:

●​ Correct Answer: @WebServlet


●​ Explanation:
○​ @WebInitParam: Incorrect. This is used inside @WebServlet to specify
initialization parameters.
○​ @MultipartConfig: Incorrect. This is used to configure how a servlet handles
multipart/form-data requests (file uploads).
○​ @WebServlet: Correct. You can provide multiple URL patterns as a string array:
@WebServlet(urlPatterns = {"/ABC", "/XYZ"}).
○​ None of these: Incorrect.
●​

Question #30: Which of the following is true about javax.servlet.error.request_uri?

●​ Correct Answer: This attribute gives information about URL calling the servlet, which
can be stored and analysed...
●​ Explanation: The Servlet specification defines several standard request attributes that
are set when an error occurs.
○​ ...gives exact error message: Incorrect. This is the job of
javax.servlet.error.message.
○​ ...gives information about exception type: Incorrect. This is the job of
javax.servlet.error.exception_type.
○​ ...gives status code: Incorrect. This is the job of javax.servlet.error.status_code.
○​ ...gives information about URL calling the servlet...: Correct. The
javax.servlet.error.request_uri attribute stores the URL of the original request that
caused the error.
●​

Question #32: What is the difference between servlets and applets?

●​ Correct Answer: i, ii are correct


●​ Explanation:
○​ i. Servlets execute on Server; Applets execute on browser: True. This is the
fundamental difference.
○​ ii. Servlets have no GUI; Applet has GUI: True. Servlets are server-side
components. Applets are client-side GUI components.

prajwalpawar
○​ iii. Servlets creates static web pages, Applets creates dynamic...: False. This is
reversed. Servlets create dynamic content, while applets are client-side
applications.
○​ iv. Servlets can handle only a single request...: False. Servlets are designed to
handle many concurrent requests.
○​ Since only i and ii are true, this is the correct choice.
●​

Question #35: <jsp:useBean id="person" class="Person" scope="request"> is equivalent


to:

●​ Correct Answer: Person person = (Person)request.getAttribute("person"); if(person ==


null){ person = new Person(); request.setAttribute("person", person); } (The image shows
new PersonBean() which is likely a typo, it should be new Person())
●​ Explanation: The <jsp:useBean> tag first looks for an attribute with the given id in the
specified scope. If it finds one, it uses it. If not, it instantiates a new object using the class
attribute and sets it as an attribute in that scope.
○​ The first option perfectly describes this "get-if-exists-else-create-and-set" logic for
the request scope.
○​ The second option incorrectly uses the response object.
○​ The third option is missing the if (person == null) check, so it would always create
a new bean, which is wrong.
●​

Question #36: Which are the session tracking techniques?

●​ Correct Answer: i, ii, iv, v


●​ Explanation:
○​ i. URL rewriting: Valid technique. The session ID is appended to URLs.
○​ ii. Using session object: Vague, but HttpSession (which uses other techniques) is
the API, so we'll count it.
○​ iii. Using response object: Invalid. The response object sends data back; it
doesn't track sessions.
○​ iv. Using hidden fields: Valid technique. The session ID is stored in a hidden form
field.
○​ v. Using cookies: Valid and most common technique. The session ID is stored in
a cookie.
○​ vi. Using servlet object: Invalid. The servlet object is the component that
processes requests, it's not a tracking technique itself.
○​ Therefore, i, ii, iv, and v are the correct techniques.
●​

Question #39: The signature of the jspInit() method is:

●​ Correct Answer: jspInit()

prajwalpawar
●​ Explanation: The jspInit() method is defined in the JspPage interface (which servlets
generated from JSPs implement).
○​ jspInit(HttpServletRequest request, HttpServletResponse response): Incorrect.
This looks like a service method signature.
○​ jspInit(): Correct. It takes no arguments, just like a servlet's destroy() method.
○​ jspInit(HttpServletRequest request, HttpServletResponse resp): Incorrect.
○​ No such method exists in the API: Incorrect. It is a key lifecycle method.
●​

Topic: Hibernate & JPA

Question #9 (Set 2): Which of the following is true about the detached state of a
persistent entity?

●​ Correct Answer: Once we close the Hibernate Session, the persistent instance will
become detached.
●​ Explanation:
○​ Once we close the Hibernate Session...: Correct. An object becomes detached
when the session it was associated with is closed. It still has a database identity
but is no longer managed by Hibernate.
○​ A new instance of a persistent class...: Incorrect. A new instance is transient.
○​ You can make a transient instance detached...: Incorrect. You make a transient
instance persistent by associating it with a session.
○​ None: Incorrect.
●​

Question #10 (Set 2): Which one of the following is not an ID generating strategy using
@GeneratedValue annotation?

●​ Correct Answer: Manual


●​ Explanation:
○​ Auto: Valid strategy. Hibernate picks the best strategy based on the database
dialect.
○​ Manual: Invalid. There is no "Manual" strategy. If you want to assign the ID
yourself, you simply omit the @GeneratedValue annotation entirely.
○​ Identity: Valid strategy. Relies on the database's auto-increment column feature.
○​ Sequence: Valid strategy. Uses a database sequence to generate IDs.
●​

Question #12 (Set 2): The SessionFactory of Hibernate represents:

●​ Correct Answer: Second Level Cache


●​ Explanation:

prajwalpawar
○​ First Level Cache: Incorrect. The Session represents the first-level cache.
○​ Second Level Cache: Correct. The SessionFactory holds the (optional)
second-level cache, which is shared across all sessions created by that factory.
○​ Third Level Cache, Fourth Level Cache: Incorrect. These are not standard
Hibernate cache levels.
●​

Question #15 (Set 2): For two transactions T1 and T2, T1 reads a field that has been
updated by T2 but not yet committed is called as:

●​ Correct Answer: Dirty Read


●​ Explanation:
○​ Dirty Read: Correct. This is the definition of a dirty read: reading uncommitted
data from another transaction. This can lead to inconsistencies if the other
transaction eventually rolls back.
○​ Nonrepeatable read: Incorrect. This occurs when a transaction reads the same
row twice and gets different values because another transaction committed an
update in between.
○​ Phantom read: Incorrect. This occurs when a transaction runs the same query
twice and gets a different set of rows because another transaction committed an
insert or delete in between.
○​ Lost Updates: Incorrect. This occurs when two transactions read, modify, and
write the same data, and one of the updates overwrites the other.
●​

Question #31: Hibernate supports polymorphism.

●​ Correct Answer: True


●​ Explanation:
○​ True: Correct. Hibernate fully supports polymorphism. You can write an HQL
query for a base class (e.g., FROM Payment) and Hibernate will automatically
retrieve instances of all its subclasses (CreditCardPayment, PaypalPayment).
This is a key feature of its ORM capabilities.
○​ False, Design specific, Database specific: Incorrect.
●​

Topic: Spring Framework

Question #3 (Set 2): Method used to process a bean before initialization callback.

●​ Correct Answer: postProcessBeforeInitialization()


●​ Explanation: This question refers to the BeanPostProcessor interface, a powerful
Spring extension point.

prajwalpawar
○​ scope: Incorrect. Scope defines the bean's lifecycle, it doesn't process it.
○​ postProcessAfterInitialization(): Incorrect. This is called after initialization
methods (like afterPropertiesSet or @PostConstruct).
○​ postProcessBeforeInitialization(): Correct. This method from the
BeanPostProcessor interface is called after the bean is instantiated but before
any custom initialization callbacks are invoked.
○​ Its own constructor: Incorrect. The constructor is called first, before any
post-processing.
●​

Question #5 (Set 2): The White Label Error:

●​ Correct Answer: can be avoided by providing the custom error controller class which
implements ErrorController
●​ Explanation: The "Whitelabel Error Page" is Spring Boot's default fallback error page.
○​ can be avoided by providing the custom error controller...: Correct. You can
completely replace the Whitelabel page by creating your own controller that
implements the ErrorController interface and mapping it to /error.
○​ can be avoided by using @GetMapping annotation: Incorrect. @GetMapping is
for normal request handling, not for global error handling.
○​ can be avoided by using @EnableAutoConfiguration annotation: Incorrect. This
annotation enables the Whitelabel page, it doesn't avoid it.
○​ Cannot be avoided: Incorrect. It is highly customizable.
●​

Question #14 (Set 2): If the class is annotated with @Component Annotation:

●​ Correct Answer: the class is found during classpath scanning and creates the bean
●​ Explanation:
○​ the class is found during classpath scanning and creates the bean: Correct. The
@Component annotation marks a class as a candidate for auto-detection. When
component scanning is enabled, Spring finds it and registers an instance of it as
a bean in the container.
○​ ...and does not create the bean: Incorrect. It does create the bean.
○​ enables autowiring for the class: Incorrect. @Component makes the class a
target for autowiring into, but @Autowired is what enables the injection itself.
○​ disables autowiring for the class: Incorrect.
●​

Question #19: A modularization of a concern which cuts across multiple classes is:

●​ Correct Answer: an Aspect


●​ Explanation: This is the definition of a key term in Aspect-Oriented Programming
(AOP).

prajwalpawar
○​ an Aspect: Correct. An aspect is the class that encapsulates a cross-cutting
concern, such as logging or transaction management, which can be applied to
multiple other classes.
○​ a Join Point: Incorrect. A join point is a specific point in the execution of a
program, such as a method call.
○​ an Advice: Incorrect. An advice is the action (the code) taken by an aspect at a
particular join point.
○​ a pointcut: Incorrect. A pointcut is an expression that selects which join points an
advice should apply to.
●​

Question #21: The Spring container gets its instructions on what objects to instantiate,
configure, and assemble by reading the:

●​ Correct Answer: configuration metadata


●​ Explanation:
○​ source code: Incorrect. The container doesn't read the raw source code.
○​ spring integration data: Incorrect. This refers to a specific Spring project, not the
core container.
○​ configuration metadata: Correct. This is the general term for the instructions
given to the container. This metadata can be in the form of XML files, Java
Annotations, or Java-based configuration classes.
○​ configuration text file: Too specific. The metadata can be in multiple formats, not
just a text file.
●​

Question #25 (Set 2): @SpringBootApplication includes?

●​ Correct Answer: All of the above


●​ Explanation: The @SpringBootApplication is a convenience annotation that bundles
three other critical annotations.
○​ E23: This is likely a typo for @Configuration.
○​ @EnableAutoConfiguration: True.
○​ @ComponentScan: True.
○​ All of the above: Correct. It includes @Configuration,
@EnableAutoConfiguration, and @ComponentScan.
●​

Question #26 (Set 2): What annotation is used to map a value to the method argument in
http://localhost/factorial/{value}?

●​ Correct Answer: @PathVariable


●​ Explanation:
○​ @Map, @Param: Incorrect. These are not standard Spring MVC annotations for
this purpose.

prajwalpawar
○​ @RequestParam: Incorrect. This is used to extract values from query parameters
(e.g., ?value=5).
○​ @PathVariable: Correct. This annotation is used to bind a value from a
placeholder in the URL path (like {value}) to a method argument.
●​

Question #38 (Set 2): Which spring module provides the capability of DI or IOC?

●​ Correct Answer: Spring Core


●​ Explanation:
○​ Spring web: Incorrect. This module is for web application development (Spring
MVC).
○​ Spring Core: Correct. The Core container (including BeanFactory and
ApplicationContext) is the heart of the framework and provides the fundamental
IoC and DI functionality.
○​ AOP: Incorrect. This module provides Aspect-Oriented Programming support.
○​ Data access: Incorrect. This module provides support for JDBC, ORM, and
transactions.
●​

Topic: General Design & Development Concepts

Question #2 (Set 2): In which of the following patterns, a class's behavior or its algorithm
can be changed at run time?

●​ Correct Answer: Strategy


●​ Explanation:
○​ Template: Incorrect. The Template Method pattern defines the skeleton of an
algorithm in a base class, allowing subclasses to redefine certain steps, but this
is a compile-time decision.
○​ Strategy: Correct. The Strategy pattern defines a family of algorithms,
encapsulates each one, and makes them interchangeable. The context object
can be configured with a different strategy object at runtime, thus changing its
behavior.
○​ State: While the State pattern also changes behavior at runtime, it does so based
on an object's internal state. Strategy is a more direct answer for changing an
algorithm.
○​ Observer: Incorrect. This pattern defines a one-to-many dependency between
objects.
●​

Question #13 (Set 2): >>@NonNull String name; Specifies that

prajwalpawar
●​ Correct Answer: name cannot be assigned with a null value
●​ Explanation: @NonNull is a common annotation (from libraries like Lombok or JSR
305) used by static analysis tools and IDEs.
○​ no such annotation as NonNull: Incorrect. It's a very common annotation.
○​ name cannot be assigned with a null value: Correct. This is its explicit meaning.
It's a contract indicating that this variable should never be null.
○​ Annotation cannot be applied to a variable: Incorrect. It is designed to be applied
to variables, parameters, and return types.
○​ Both A & C: Incorrect.
●​

Question #17 (Set 2): Uses of Annotations:

●​ Correct Answer: All of the above


●​ Explanation: Annotations have multiple uses in the Java ecosystem.
○​ Compiler can use annotations...: True. E.g., @Override to detect errors or
@SuppressWarnings to suppress warnings.
○​ Annotation information can be processed to generate code, XML...: True. This is
called annotation processing (e.g., Lombok generates getters/setters).
○​ Some annotations can be processed at runtime: True. E.g., Spring uses
reflection to read annotations like @Component at runtime.
○​ All of the above: Correct. All listed uses are valid.
●​

Question #18 (Set 2): Which of the following describes the Bridge pattern correctly?

●​ Correct Answer: This pattern is used when we need to decouple an abstraction from its
implementation so that the two can vary independently.
●​ Explanation:
○​ This pattern builds a complex object using simple objects...: This describes the
Builder pattern.
○​ This pattern refers to creating duplicate object...: This describes the Prototype
pattern.
○​ This pattern is used when creation of object directly is costly: This could describe
the Flyweight or Proxy pattern.
○​ This pattern is used when we need to decouple an abstraction from its
implementation...: Correct. This is the textbook definition of the Bridge pattern. It
separates an abstraction's interface from its implementation, allowing you to
change them independently.
●​

Question #20 (Set 2): Which of the following statements are correct about the status of
the Http response?

●​ Correct Answer: A status of 200 to 299 signifies that the request was successful.

prajwalpawar
●​ Explanation:
○​ A status of 200 to 299 signifies that the request was successful: Correct. This is
the "Successful" class of status codes.
○​ A status of 300 to 399 are informational messages: Incorrect. This is the
"Redirection" class of codes. 1xx are informational.
○​ A status of 400 to 499 indicates an error in the server: Incorrect. This is the
"Client Error" class of codes (e.g., 404 Not Found).
○​ A status of 500 to 599 indicates an error in the client: Incorrect. This is the
"Server Error" class of codes (e.g., 500 Internal Server Error).
●​

Question #22 (Set 2): Which of the following depicts best practice, Linkability for
resource representation in REST?

●​ Correct Answer: A resource can have a linkage to another resource, a format should be
able to express it.
●​ Explanation: This question refers to HATEOAS (Hypermedia as the Engine of
Application State), a key constraint of REST.
○​ Both Server and Client should be able to understand...: This is a general
principle, not specific to linkability.
○​ Format should be able to represent a resource completely...: This is about
resource representation, not links.
○​ A resource can have a linkage to another resource...: Correct. This is the
essence of HATEOAS. A resource representation should contain links
(hypermedia) to related actions or resources, allowing the client to navigate the
API dynamically.
○​ None of the above: Incorrect.
●​

Question #23 (Set 2): Which of the following statement/s is/are correct?

●​ Correct Answer: All of the above


●​ Explanation: This compares Ant and Maven.
○​ Ant is a tool box and Maven is a framework: True. Ant provides tasks (a toolbox),
while Maven enforces a convention-based framework.
○​ Ant is a build tool and Maven is a Project Management Tool: True. Maven goes
beyond just building; it manages dependencies, reporting, and the project
lifecycle.
○​ In Ant project structure needs to be provided in build.xml, in Maven it is defined in
pom.xml: True. Ant is procedural (you define the how in build.xml), while Maven
is declarative (you define the what in pom.xml and it follows conventions).
○​ All of the above: Correct. All statements are valid comparisons.
●​

prajwalpawar
Question #24 (Set 2): Which of the following component of HTTP response contains
response message content or Resource representation?

●​ Correct Answer: Response Body


●​ Explanation:
○​ Status/Response Code: Part of the status line; indicates success or failure.
○​ HTTP Version: Part of the status line.
○​ Response Header: Contains metadata about the response (e.g., Content-Type).
○​ Response Body: Correct. This is the payload of the message, containing the
actual resource data (e.g., HTML, JSON).
●​

Question #27 (Set 2): Which design pattern works on data and an action is taken based
on data provided?

●​ Correct Answer: Command


●​ Explanation:
○​ Singleton: Ensures a class has only one instance.
○​ Facade: Provides a simplified interface to a complex subsystem.
○​ Command: Correct. The Command pattern encapsulates a request as an object,
thereby letting you parameterize clients with different requests, queue or log
requests, and support undoable operations. The "data" is the request itself, and
the "action" is its execution.
○​ MVC: An architectural pattern, not a behavioral one in this specific sense.
●​

Question #29: Singleton design pattern:

●​ Correct Answer: Only one instance of class is created and returned every time
●​ Explanation:
○​ can have multiple instances of classes...: Incorrect. This violates the pattern.
○​ Only one instance of class is created and returned every time: Correct. This is
the definition of the Singleton pattern. It ensures that a class has only one
instance and provides a global point of access to it.
○​ does not exists: Incorrect. It's a fundamental design pattern.
○​ Only one reference of interface can be created: Incorrect. The pattern applies to
class instances, not interface references.
●​

Question #34: The pom.xml can inherit the dependencies from another pom.xml using:

●​ Correct Answer: <parent>


●​ Explanation:

prajwalpawar
○​ <parent>: Correct. The <parent> tag is used in a child POM to inherit
configuration, including dependencies and properties, from a parent POM. This is
fundamental to multi-module Maven projects.
○​ <artifactId>: Incorrect. This is the name of the project artifact.
○​ <dependency>: Incorrect. This is used to declare a single dependency, not to
inherit from another POM.
○​ <groupId>: Incorrect. This is the group identifier for the project.
●​

Question #40 (Set 2): The syntax for the creation of a Custom marker annotation having
runtime visibility and that can be used for all types

●​ Correct Answer: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)


public @interface CustomAnnotation {} (The last option is the closest)
●​ Explanation:
○​ @Retention(RetentionPolicy.RUNTIME): Correct for runtime visibility.
○​ @Target(ElementType.ALL): Incorrect. There is no ElementType.ALL.
○​ @Target(ElementType.TYPE): Correct for applying to types (classes, interfaces,
enums). The question says "all types", which implies this target.
○​ The last option is the most correct, although @Target is not strictly necessary for
a "marker annotation" if it can be applied anywhere, but TYPE is the most
common for class-level markers. The one with ElementType.ALL would be
correct if ALL existed, but it doesn't. Therefore, the last option is the intended
answer.
●​

prajwalpawar
SET 3 :

Of course. I will extract and analyze only the questions relevant to your Advanced Java syllabus
(Servlets, JSP, JDBC, Hibernate, Spring, Design Patterns, Maven, HTTP/REST Concepts). The
other questions (SQL, Core Java, Data Structures, JavaScript, React, etc.) will be ignored as
requested.

Here is the topic-wise breakdown with detailed explanations.

Topic: Servlets & JSP

Question #28: The annotation used for declaring a servlet with multiple URL patterns
(e.g. /ABC, /XYZ) is:

●​ Correct Answer: @WebServlet


●​ Explanation:
○​ @WebInitParam: Incorrect. This annotation is used inside @WebServlet to
define initialization parameters for the servlet.
○​ @MultipartConfig: Incorrect. This annotation is placed on a servlet to indicate
that it can handle multipart/form-data requests, which are typically used for file
uploads.
○​ @WebServlet: Correct. This is the standard annotation for declaring a class as a
servlet. To map multiple URL patterns, you provide them as a string array, like
this: @WebServlet(urlPatterns = {"/ABC", "/XYZ"}).
○​ None of these: Incorrect, as @WebServlet is the correct answer.
●​

Question #30: Which of the following is true about javax.servlet.error.request_uri?

●​ Correct Answer: This attribute gives information about URL calling the servlet...
●​ Explanation: When an error occurs and you use an error page, the servlet container
sets several standard attributes in the request scope to provide information about the
error.
○​ ...gives exact error message...: Incorrect. This is the purpose of the
javax.servlet.error.message attribute.
○​ ...gives information about exception type...: Incorrect. This is the purpose of the
javax.servlet.error.exception_type attribute.
○​ ...gives status code...: Incorrect. This is the purpose of the
javax.servlet.error.status_code attribute.
○​ ...gives information about URL calling the servlet...: Correct. The
javax.servlet.error.request_uri attribute stores the string value of the original URL
that was called by the client and resulted in the error.

prajwalpawar
●​

Question #32: What is the difference between servlets and applets?

●​ Correct Answer: i, ii are correct


●​ Explanation:
○​ Statement i: Servlets execute on Server; Applets execute on browser. This is
true. It's the fundamental distinction: servlets are server-side, applets are
client-side.
○​ Statement ii: Servlets have no GUI; Applet has GUI. This is true. Servlets are
backend components that generate responses (like HTML), while Applets were
GUI applications that ran in the browser.
○​ Statement iii: Servlets creates static web pages, Applets creates dynamic web
pages. This is false. It's the reverse; servlets are designed to create dynamic
content.
○​ Statement iv: Servlets can handle only a single request; Applet can handle
multiple requests. This is false. Servlets are multi-threaded and designed to
handle many concurrent requests.
○​ Therefore, only statements i and ii are correct.
●​

Question #35: <jsp:useBean id="person" class="Person" scope="request"> is equivalent


to:

●​ Correct Answer: The first option: Person person =


(Person)request.getAttribute("person"); if(person == null){ person = new PersonBean();
request.setAttribute("person", person); } (Assuming PersonBean is a typo for Person).
●​ Explanation: The <jsp:useBean> action tag follows a specific logic:
○​ It looks for an object in the specified scope (request) with the name specified by
id (person).
○​ If it finds the object, it does nothing more than make it available as a scripting
variable.
○​ If it does not find the object, it instantiates a new one using the class attribute
(new Person()) and then sets it as an attribute in the specified scope.
○​ The first option perfectly implements this get-if-exists-or-create-and-set logic.
○​ The second option incorrectly uses the response object.
○​ The third option is missing the if (person == null) check and would always create
a new object, which is not how <jsp:useBean> works.
●​

Question #36: Which are the session tracking techniques?

●​ Correct Answer: i, ii, iv, v


●​ Explanation:
○​ i. URL rewriting: Valid. The session ID is appended to every URL.

prajwalpawar
○​ ii. Using session object: This is technically the API (HttpSession) you use, which
in turn relies on one of the other techniques. It's often included in lists like this.
○​ iii. Using response object: Invalid. The response object sends data; it's not a
tracking mechanism itself.
○​ iv. Using hidden fields: Valid. The session ID can be passed in hidden <input>
fields in forms.
○​ v. Using cookies: Valid. This is the most common method, where the session ID
is stored in a cookie.
○​ vi. Using servlet object: Invalid. The servlet is the processor, not the tracking
technique.
●​

Question #39: The signature of the jspInit() method is:

●​ Correct Answer: jspInit()


●​ Explanation:
○​ jspInit(HttpServletRequest request, HttpServletResponse response): Incorrect.
This signature resembles a service method, not an initialization method.
○​ jspInit(): Correct. The jspInit() method, defined in the JspPage interface, takes no
arguments. It's called once when the JSP-turned-servlet is initialized.
○​ jspInit(HttpServletRequest request, HttpServletResponse resp): Incorrect. Same
reason as the first option.
○​ No such method exists in the API: Incorrect. It is a key part of the JSP lifecycle.
●​

Question #11 (from another image set): which of the following is not a scope in jsp

●​ Correct Answer: response


●​ Explanation:
○​ session: Valid scope. The object lives across multiple requests from the same
user.
○​ request: Valid scope. The object lives for a single HTTP request.
○​ response: Invalid scope. The response is an object used to send data back to
the client; it is not a scope for storing attributes.
○​ page: Valid scope. The object lives only for the current JSP page.
●​

Question #16 (from another image set): ...The preferred way to read the y value in the jsp
is by using...

●​ Correct Answer: actions (Implying JSP EL, which is used with standard and custom
action tags)
●​ Explanation: The code shows a Spring MVC controller method adding an object with
the key "y" to a ModelAndView object. This makes "y" available in the request scope.
○​ custom tags: Possible, but too specific.

prajwalpawar
○​ scriptlets: Bad practice. Using <%= request.getAttribute("y") %> is discouraged
in modern MVC.
○​ directives: Incorrect. Directives (<%@ ... %>) are for page settings, not for
reading data.
○​ actions: Best available answer. This broadly refers to using standard actions
like JSTL (<c:out value="${y}"/>) or Expression Language (${y}) directly in the
JSP body, which is the modern, preferred way.
●​

Question #22 (from another image set): doGet and doPost methods return

●​ Correct Answer: void


●​ Explanation:
○​ int: Incorrect. executeUpdate() in JDBC returns an int.
○​ void: Correct. The signatures are protected void doGet(...) and protected void
doPost(...). They don't return a value; instead, they operate on the
HttpServletResponse object to send a response back to the client.
○​ String: Incorrect. Controller methods in Spring MVC often return a String, but
standard servlets do not.
○​ none of the above: Incorrect.
●​

Question #31 (from another image set): The method which gets called everytime a
request is made in the servlet is

●​ Correct Answer: service


●​ Explanation:
○​ requestProcess: Incorrect. Not a standard servlet lifecycle method.
○​ service: Correct. The service() method is the entry point called by the container
for every single request.
○​ initialize: Incorrect. The initialization method is init(), and it's only called once.
○​ none of the above: Incorrect.
●​

Question #33 (from another image set): <jsp:useBean id="x" class="y" scope="request">
this is in jsp is called as

●​ Correct Answer: action


●​ Explanation:
○​ action: Correct. Any tag starting with jsp: is a standard JSP Action tag. They
perform actions at request time.
○​ directive: Incorrect. Directives start with <%@ ... %>.
○​ declaration: Incorrect. Declarations start with <%! ... %>.
○​ none of the above: Incorrect.
●​

prajwalpawar
Question #34 (from another image set): to handle 404 in jee web applications of jee, we
configure the file

●​ Correct Answer: web.xml


●​ Explanation:
○​ http.xml, 404.xml: Incorrect. These are not standard configuration file names.
○​ web.xml: Correct. You can configure custom error pages in the web.xml
deployment descriptor using the <error-page> tag, mapping a specific error code
(like 404) or exception type to a URL.
○​ none of the above: Incorrect.
●​

Topic: Hibernate & JPA

Question #9 (Set 2): Which of the following is true about detached state of a persistent
entity?

●​ Correct Answer: Once we close the Hibernate Session, the persistent instance will
become detached.
●​ Explanation:
○​ Once we close the Hibernate Session...: Correct. An object that was previously
in the persistent state (managed by the session) becomes detached once that
session is closed. It retains its database identity but is no longer tracked for
changes.
○​ A new instance of a persistent class...: Incorrect. A new instance is transient.
○​ You can make a transient instance detached...: Incorrect. You transition a
transient instance to persistent.
○​ None: Incorrect.
●​

Question #10 (Set 2): Which one of the following is not an ID generating strategy using
@GeneratedValue annotation?

●​ Correct Answer: Manual


●​ Explanation:
○​ Auto: Valid strategy. Hibernate selects an appropriate strategy based on the
database dialect.
○​ Manual: Invalid. To manually assign an ID, you simply omit the
@GeneratedValue annotation. There is no GenerationType.MANUAL.
○​ Identity: Valid strategy. Uses the database's auto-increment feature.
○​ Sequence: Valid strategy. Uses a database sequence.
●​

prajwalpawar
Question #12 (Set 2): The SessionFactory of Hibernate represents:

●​ Correct Answer: Second Level Cache


●​ Explanation:
○​ First Level Cache: Incorrect. The Session object represents the first-level cache.
○​ Second Level Cache: Correct. The SessionFactory is the holder and manager of
the optional, shared second-level cache.
○​ Third Level Cache, Fourth Level Cache: Incorrect. These are not standard
Hibernate concepts.
●​

Question #18 (from another image set): In Hibernate when we give X x =


session.get(X.class, ?), here ? is

●​ Correct Answer: primary key value which is serializable


●​ Explanation: The session.get() method retrieves an entity instance by its unique
identifier.
○​ tablename: Incorrect. The table name is derived from the class (X.class).
○​ primary key value which is serializable: Correct. The second argument must be
the primary key of the entity you want to load. The JPA specification requires that
primary keys be Serializable.
○​ databasename: Incorrect. The database name is part of the connection
configuration, not a parameter for get().
○​ none of the above: Incorrect.
●​

Question #19 (from another image set): <mapping class="?"> ? here contains

●​ Correct Answer: name of the Entity class


●​ Explanation: This tag is from the older XML-based Hibernate configuration
(hibernate.cfg.xml).
○​ name of the DAO class: Incorrect. The DAO is not mapped here.
○​ name of the Entity class: Correct. The mapping tag is used to tell Hibernate
which annotated entity classes it needs to manage. You provide the fully qualified
class name (e.g., com.example.model.User).
○​ name of the configuration file: Incorrect.
○​ none of the above: Incorrect.
●​

Question #31 (Set 1): Hibernate supports polymorphism.

●​ Correct Answer: True


●​ Explanation:
○​ True: Correct. This is a key feature of an ORM. If you query for a base class
(e.g., FROM Animal), Hibernate will correctly retrieve instances of its subclasses

prajwalpawar
(e.g., Dog, Cat) that are stored in the database, respecting the inheritance
strategy.
○​ False, Design specific, Database specific: Incorrect.
●​

Topic: Spring Framework

Question #3 (Set 2): Method used to process bean before initialization callback.

●​ Correct Answer: postProcessBeforeInitialization()


●​ Explanation: This refers to the BeanPostProcessor interface.
○​ scope: Incorrect. This defines bean lifecycle, not a processing callback.
○​ postProcessAfterInitialization(): Incorrect. This is called after initialization.
○​ postProcessBeforeInitialization(): Correct. This method is called after bean
instantiation but before init-methods like @PostConstruct are invoked.
○​ Its own constructor: Incorrect. The constructor runs before any post-processing.
●​

Question #5 (Set 2): The White Label Error:

●​ Correct Answer: can be avoided by providing the custom error controller class which
implements ErrorController
●​ Explanation:
○​ can be avoided by providing the custom error controller...: Correct. This is the
standard way to completely replace Spring Boot's default error page.
○​ can be avoided by using @GetMapping annotation: Incorrect. @GetMapping
defines a regular endpoint, not an error handler.
○​ can be avoided by using @EnableAutoConfiguration annotation: Incorrect. This
annotation is what enables the Whitelabel page in the first place.
○​ Cannot be avoided: Incorrect. It is designed to be overridden.
●​

Question #13 (from another image set): ...What Annotation should we use on
StockController

●​ Correct Answer: @RestController


●​ Explanation: A controller that handles web requests and directly returns data (like
JSON/XML) instead of a view name is a REST controller.
○​ @RestController: Correct. This is a convenience annotation that combines
@Controller and @ResponseBody, indicating that the return value of methods
should be written directly to the response body.
○​ @Presentation: Incorrect. Not a standard Spring annotation.
○​ @Repository: Incorrect. This is for the data access layer (DAOs).

prajwalpawar
○​ @Autowired: Incorrect. This is for dependency injection.
●​

Question #14 (Set 2): If the class is annotated with @Component Annotation:

●​ Correct Answer: the class is found during classpath scanning and creates the bean
●​ Explanation:
○​ the class is found during classpath scanning and creates the bean: Correct.
@Component marks a class as a candidate for Spring to manage. The
component scanner finds it and instantiates it as a bean in the container.
○​ ... and does not create the bean: Incorrect.
○​ enables autowiring for the class: Incorrect. @Autowired enables injection;
@Component makes the class a target for injection.
○​ disables autowiring for the class: Incorrect.
●​

Question #20 (from another image set): In the following code, spring will create which
objects

●​ Correct Answer: both UserController and UserService object


●​ Explanation: Spring's component scanner will detect the @RestController (which is a
form of @Component) on UserController and create a bean for it. To satisfy the
@Autowired dependency, it will look for a bean that implements the UserService
interface. Assuming such a bean exists (e.g., a UserServiceImpl class annotated with
@Service), Spring will create that bean as well. Therefore, it creates both.

Question #21 (from another image set): @Repository public interface UserRepository ...
this class that implements this interface has to be implemented by

●​ Correct Answer: Spring


●​ Explanation: This shows a Spring Data JPA repository.
○​ Programmer: Incorrect. The programmer defines the interface but does not need
to write the implementation class.
○​ Spring: Correct. Spring Data JPA dynamically creates a proxy class at runtime
that implements this interface. It analyzes the method names (like findById,
findAll) and provides the necessary Hibernate/JPA code to execute them.
○​ depends on ... application.properties: Incorrect.
○​ none of the above: Incorrect.
●​

Question #25 (Set 2): @SpringBootApplication includes?

●​ Correct Answer: All of the above


●​ Explanation:
○​ E23: Assuming this is a typo for @Configuration, this is true.
○​ @EnableAutoConfiguration: True.

prajwalpawar
○​ @ComponentScan: True.
○​ All of the above: Correct. @SpringBootApplication is a meta-annotation that
combines these three essential annotations.
●​

Question #26 (Set 2): What annotation is used to map a value to the method argument in
http://localhost/factorial/{value}?

●​ Correct Answer: @PathVariable


●​ Explanation:
○​ @Map, @Param: Not standard Spring MVC annotations for this task.
○​ @RequestParam: Incorrect. Used for query parameters (?key=value).
○​ @PathVariable: Correct. Used to bind a value from a placeholder in the URL
path (a path variable) to a method argument.
●​

Question #29 (from another image set): to call a webservice from Spring, we need to use

●​ Correct Answer: RestTemplate


●​ Explanation:
○​ CallWS, CallWSviaJSON: Incorrect. These are not Spring classes.
○​ RestTemplate: Correct. RestTemplate is the classic Spring class for making
client-side REST calls. (The modern alternative is WebClient).
○​ none of the above: Incorrect.
●​

Question #30 (from another image set): to change tomcat port no in spring boot, property
used in application.properties is.

●​ Correct Answer: server.port


●​ Explanation:
○​ catalina.port: Incorrect.
○​ server.port: Correct. This is the standard Spring Boot property for configuring the
embedded server's port.
○​ port.number: Incorrect.
○​ none of the above: Incorrect.
●​

Question #35 (from another image set): @autowired can be used at

●​ Correct Answer: both function and variable level (and constructor level)
●​ Explanation: Spring supports multiple types of dependency injection.
○​ function level (Setter/Method Injection): Valid.
○​ variable level (Field Injection): Valid.
○​ both function and variable level: Correct. Since it can be used on both (as well
as constructors), this is the most accurate choice.

prajwalpawar
○​ none of the above: Incorrect.
●​

Question #36 (from another image set): which of the following annotation is used at
function level

●​ Correct Answer: @Bean


●​ Explanation:
○​ @component, @Repository: These are class-level annotations.
○​ @Bean: Correct. The @Bean annotation is placed on a method (function) within
a @Configuration class to declare that the object returned by the method should
be registered as a bean in the Spring container.
○​ all the above: Incorrect.
●​

Question #38 (Set 2): Which spring module provides the capability of DI or IOC?

●​ Correct Answer: Spring Core


●​ Explanation:
○​ Spring web: Incorrect. This is for web applications.
○​ Spring Core: Correct. The Core Container module provides the fundamental IoC
and DI features.
○​ AOP: Incorrect. This is for Aspect-Oriented Programming.
○​ Data access: Incorrect. This is for JDBC, ORM, etc.
●​

Question (unnumbered): The function present in CommandLineRunner interface in


spring is

●​ Correct Answer: run


●​ Explanation:
○​ run: Correct. The CommandLineRunner is a functional interface with a single
abstract method: void run(String... args).
○​ runner, runTask: Incorrect.
○​ none of the above: Incorrect.
●​

Topic: General Concepts (Design Patterns, Maven, HTTP)

Question #24: which of the following is true for postman

●​ Correct Answer: postman is used to test web services.


●​ Explanation:

prajwalpawar
○​ postman is used to test web services: Correct. Postman is a very popular API
platform used for building, testing, and documenting APIs, especially RESTful
web services.
○​ postman is a tool to test our database queries: Incorrect. Tools like MySQL
Workbench or DBeaver are for this.
○​ postman is a tool to test css and html: Incorrect. This is done directly in a web
browser.
○​ none of the above: Incorrect.
●​

Question #25: test, compile, verify in maven are called as

●​ Correct Answer: phases


●​ Explanation:
○​ phases: Correct. The Maven build lifecycle is composed of a sequence of
phases, such as validate, compile, test, package, verify, install, and deploy.
○​ goals: Incorrect. A goal is a specific task (e.g., compiler:compile) that is bound to
a phase.
○​ lifecycle: Incorrect. default, clean, and site are the lifecycles. The items listed are
phases within a lifecycle.
○​ none of the above: Incorrect.
●​

Question #29: Singleton design pattern:

●​ Correct Answer: Only one instance of class is created and returned every time
●​ Explanation:
○​ can have multiple instances...: Incorrect.
○​ Only one instance of class is created and returned every time: Correct. This is
the definition of the Singleton pattern.
○​ does not exists: Incorrect.
○​ Only one reference of interface...: Incorrect. The pattern applies to class
instances.
●​

Question #34: The pom.xml can inherit the dependencies from another pom.xml using:

●​ Correct Answer: <parent>


●​ Explanation:
○​ <parent>: Correct. This tag is used in a child module's POM to inherit
configuration from a parent POM.
○​ <artifactId>, <dependency>, <groupId>: Incorrect. These tags have different
purposes.
●​

prajwalpawar
Question (unnumbered): ________ is the command to invoke some specific maven
functionality in command line

●​ Correct Answer: mvn


●​ Explanation:
○​ maven: Incorrect.
○​ build: Incorrect.
○​ mvn: Correct. mvn is the command-line executable for running Maven
commands (e.g., mvn clean install).
○​ none of the above: Incorrect.
●​

prajwalpawar

You might also like