120
89.9k

220+ Advanced JAVA Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Master of Science in Information Technology (MSc IT) , Master of Science in Computer Science (MSc CS) , Bachelor of Business Administration in Computer Applications (BBA [CA]) , Programming Languages , Master of Science in Software Engineering (MSc SE) .

Chapters

Chapter: Servlet and Overview
51.

Sessions is a part of the SessionTracking and it is for maintaining the client state at server side.

A. True
B. False
C. none
D. all
Answer» A. True
52.

When destroy() method of a filter is called?

A. The destroy() method is called only once at the end of the life cycle of a filter
B. The destroy() method is called after the filter has executed doFilter method
C. The destroy() method is called only once at the begining of the life cycle of a filter
D. The destroyer() method is called after the filter has executed
Answer» A. The destroy() method is called only once at the end of the life cycle of a filter
53.

Web server is used for loading the init() method of servlet.

A. True
B. False
C. none
D. all
Answer» A. True
54.

Servlets handle multiple simultaneous requests by using threads.

A. True
B. False
C. none
D. all
Answer» A. True
55.

Which method is used to send the same request and response objects to another servlet in RequestDispacher ?

A. forward()
B. sendRedirect()
C. Both A & B
D. None of the above
Answer» A. forward()
56.

The sendRedirect() method of HttpServletResponse interface can be used to redirect response to another resource, it may be servlet, jsp or html file

A. True
B. False
C. none
D. all
Answer» A. True
57.

Which packages represent interfaces and classes for servlet API?

A. javax.servlet
B. javax.servlet.http
C. Both A & B
D. None of the above
Answer» C. Both A & B
58.

Which class can handle any type of request so that it is protocol-independent?

A. GenericServlet
B. HttpServle
C. Both A & B
D. None of the above
Answer» A. GenericServlet
59.

Which HTTP Request method is non-idempotent?

A. GET
B. POST
C. Both A & B
D. None of the above
Answer» C. Both A & B
60.

Which object is created by the web container at time of deploying the project?

A. ServletConfig
B. ServletContext
C. Both A & B
D. None of the above
Answer» B. ServletContext
61.

What is the lifecycle of a servlet?

A. Servlet class is loaded
B. Servlet instance is created
C. init,Service,destroy method is invoked
D. All mentioned above
Answer» D. All mentioned above
62.

Which method in session tracking is used in a bit of information that is sent by a web server to a browser and which can later be read back from that browser?

A. HttpSession
B. URL rewriting
C. Cookies
D. Hidden form fields
Answer» C. Cookies
63.

Which are the examples of Application Server?

A. Apache
B. Tomcat
C. JBoss
D. Weblogic
Answer» C. JBoss
64.

How many techniques are used in Session Tracking?

A. 4
B. 3
C. 2
D. 5
Answer» A. 4
65.

In HTTP Request method Get request is secured because data is exposed in URL bar

A. True
B. False
C. none
D. all
Answer» B. False
66.

In the following statements identify the disadvantages of CGI?

A. If number of clients increases, it takes more time for sending response
B. For each request, it starts a process and Web server is limited to start processes
C. It uses platform dependent language e.g. C, C++, perl
D. All mentioned above
Answer» D. All mentioned above
67.

Servlet technology is used to create web application

A. True
B. False
C. none
D. all
Answer» A. True
68.

Which method is used to specify before any lines that uses the PintWriter?

A. setPageType()
B. setContextType()
C. setContentType()
D. setResponseType()
Answer» C. setContentType()
69.

What are functions of Servlet container?

A. Lifecycle management
B. Communication Support
C. Multithreading Support
D. All of the above
Answer» D. All of the above
70.

Which object of HttpSession can be used to view and manipulate information about a session?

A. session identifier
B. creation time
C. last accessed time
D. All mentioned above
Answer» D. All mentioned above
71.

Which methods are used to bind the objects on HttpSession instance and get the objects?

A. setAttribute
B. getAttribute
C. Both A & B
D. None of the above
Answer» C. Both A & B
72.

Which method take a string not a URL?

A. sendRedirect
B. forward
C. Both
D. None
Answer» A. sendRedirect
73.

Which of the following are interface?
1. ServletContext
2. Servlet
3. GenericServlet
4. HttpServlet

A. 1,2,3,4
B. 1,2
C. 1,2,3
D. 1,4
Answer» B. 1,2
74.

The life cycle of a servlet is managed by

A. servlet context
B. servlet container
C. the supporting protocol (such as http or https)
D. All of the above
Answer» B. servlet container
75.

Which of the following code is used to get an attribute in a HTTP Session object in servlets?

A. session.getAttribute(String name)
B. session.alterAttribute(String name)
C. session.updateAttribute(String name)
D. session.setAttribute(String name)
Answer» A. session.getAttribute(String name)
76.

What is the difference between servlets and applets? i. Servlets execute on Server; Applets execute on browser ii. Servlets have no GUI; Applet has GUI iii. Servlets creates static web pages; Applets creates dynamic web pages iv. Servlets can handle only a single request; Applet can handle multiple requests

A. i, ii, iii are correct
B. i, ii are correct
C. i, iii are correct
D. i, ii, iii, iv are correct
Answer» B. i, ii are correct
77.

Which are the session tracking techniques? i. URL rewriting ii. Using session object iii.Using response object iv. Using hidden fields v. Using cookies vi. Using servlet object

A. i, ii, iii, vi
B. i, ii, iv, v
C. i, vi, iii, v
D. i, ii, iii, v
Answer» B. i, ii, iv, v
78.

A deployment descriptor describes

A. Web component response settings
B. Web component setting
C. Web component request objects
D. All of the above
Answer» B. Web component setting
79.

The values of <servlet-name> and <servlet-class> in web.xml file

A. must be same
B. must not be same
C. may be same
D. None of the above
Answer» C. may be same
Chapter: JSP
80.

Which one is the correct order of phases in JSP life cycle?

A. Initialization, Cleanup, Compilation, Execution
B. Initialization, Compilation, Cleanup, Execution
C. Compilation, Initialization, Execution, Cleanup
D. Cleanup, Compilation, Initialization, Execution
Answer» C. Compilation, Initialization, Execution, Cleanup
81.

Which technology do we mix our business logic with the presentation logic?

A. Servlet
B. JSP
C. Both A and B
D. None of the above
Answer» A. Servlet
82.

Which attribute specifies a JSP page that should process any exceptions thrown but not caught in the current page?

A. The ErrorPage Attribute
B. The IsErrorPage Attribute
C. Both A & B
D. None of the above
Answer» A. The ErrorPage Attribute
83.

The ASP and JSP technologies are quite similar in the way they support the creation of Dynamic pages, using HTML templates, scripting code and components for business logic.

A. True
B. False
C. none
D. all
Answer» A. True
84.

Which of the following is an advantage of the statement – Separation of business logic from JSP ?

A. Custom Tags in JSP
B. JSP Standard Tag Library
C. All the above
D. None of the above
Answer» A. Custom Tags in JSP
85.

JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you can do with Java servlets.

A. True
B. False
C. none
D. all
Answer» A. True
86.

JavaServer Pages often serve the same purpose as programs implemented using the Common Gateway Interface (CGI)

A. True
B. False
C. none
D. all
Answer» A. True
87.

Which is the Microsoft solution for providing dynamic Web content?

A. ASP
B. JSP
C. Both A and B
D. None of the above
Answer» A. ASP
88.

Which tag is used to execute java source code in JSP?

A. Declaration Tag
B. Scriptlet tag
C. Expression tag
D. None of the above
Answer» B. Scriptlet tag
89.

A JSP page consists of which tags?

A. HTML tags
B. JSP tags
C. Both A & B
D. None of the above
Answer» C. Both A & B
90.

Which packages does a JSP API consist of?

A. javax.servlet.jsp
B. java.servlet
C. javax.servlet.jsp.tagext
D. Both A & C
Answer» D. Both A & C
91.

Which of the scripting of JSP not putting content into service method of the converted servlet?

A. Declarations
B. Scriptlets
C. Expressions
D. None of the above
Answer» C. Expressions
92.

The difference between Servlets and JSP is the …………….

A. translation
B. compilation
C. syntax
D. Both A and B
Answer» C. syntax
93.

Which of the following are the valid scopes in JSP?

A. request, page, session, application
B. request, page, session, global
C. response, page, session, application
D. request, page, context, application
Answer» A. request, page, session, application
94.

JSP includes a mechanism for defining …………………………. or custom tags.

A. static attributes
B. local attributes
C. dynamic attributes
D. global attributes
Answer» C. dynamic attributes
95.

Why DB connections are not written directly in JSPs?

A. Response is slow
B. Not a standard J2EE architecture
C. Load Balancing is not possible
D. Both B and C
Answer» D. Both B and C
96.

Which is not a directive?

A. include
B. page
C. export
D. taglib
Answer» C. export
97.

Which http method send by browser that asks the server to get the page only?

A. get
B. option
C. put
D. post
Answer» A. get
98.

Which tag should be used to pass information from JSP to included JSP?

A. Using <%jsp:page> tag
B. Using <%jsp:param> tag
C. Using <%jsp:import> tag
D. Using <%jsp:useBean> tag
Answer» B. Using <%jsp:param> tag
99.

_jspService() method of HttpJspPage class should not be overridden.

A. True
B. False
C. none
D. all
Answer» A. True
100.

Which is not a directive?

A. include
B. page
C. export
D. useBean
Answer» C. export

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.