Explore topic-wise MCQs in Advanced Java.

This section includes 11 Mcqs, each offering curated multiple-choice questions to sharpen your Advanced Java knowledge and support exam preparation. Choose a topic below to get started.

1.

Which are the session tracking techniques?i. URL rewritingii. Using session objectiii.Using response objectiv. Using hidden fieldsv. Using cookiesvi. Using servlet object

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

Which of the following is true about servlets?

A. Servlets execute within the address space of web server
B. Servlets are platform-independent because they are written in java
C. Servlets can use the full functionality of the Java class libraries
D. Servlets execute within the address space of web server, platform independent and uses the functionality of java class libraries
Answer» E.
3.

Which of the following code retrieves the body of the request as binary data?

A. DataInputStream data = new InputStream()
B. DataInputStream data = response.getInputStream()
C. DataInputStream data = request.getInputStream()
D. DataInputStream data = request.fetchInputStream()
Answer» D. DataInputStream data = request.fetchInputStream()
4.

Which method is used to get three-letter abbreviation for locale’s country in servlets?

A. Request.getISO3Country()
B. Locale.getISO3Country()
C. Response.getISO3Country()
D. Local.retrieveISO3Country()
Answer» B. Locale.getISO3Country()
5.

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 nam
E. session.alterAttribute(String name)c) session.updateAttribute(String name)d) session.setAttribute(String name)
Answer» B. session.alterAttribute(String name)
6.

What is the difference between servlets and applets?i. Servlets execute on Server; Applets execute on browserii. Servlets have no GUI; Applet has GUIiii. Servlets creates static web pages; Applets creates dynamic web pagesiv. 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» C. i, iii are correct
7.

How constructor can be used for a servlet?

A. Initialization
B. Constructor function
C. Initialization and Constructor function
D. Setup() method
Answer» D. Setup() method
8.

How is the dynamic interception of requests and responses to transform the information done?

A. servlet container
B. servlet config
C. servlet context
D. servlet filter
Answer» E.
9.

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» B. The destroy() method is called after the filter has executed doFilter method
10.

Which method is used to get three-letter abbreviation for locale’s country in servlets?$

A. Request.getISO3Country()
B. Locale.getISO3Country()
C. Response.getISO3Country()
D. Local.retrieveISO3Country()
Answer» B. Locale.getISO3Country()
11.

Can servlet class declare constructor with ServletConfig object as an argument?

A. True
B. False
Answer» C.