Explore topic-wise InterviewSolutions in .

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

1.

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 filterI have been asked this question during an interview.I would like to ask this question from Servlet in division Java Server Technologies & Servlet of Java

Answer»

Right option is (d) SERVLET filter

The best explanation: Servlet has various components like container, config, context, filter. Servlet filter PROVIDES the dynamic INTERCEPTION of REQUESTS and responses to TRANSFORM the information.

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 librariesThe question was asked during an online exam.Question is from Servlet topic in section Java Server Technologies & Servlet of Java

Answer»

Correct option is (d) Servlets execute within the ADDRESS space of web server, platform independent and uses the functionality of JAVA class libraries

Easiest explanation: Servlets execute within the address space of a web server. Since it is written in java it is platform independent. The full functionality is AVAILABLE through libraries.

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()I got this question in examination.The question is from Servlet in chapter Java Server Technologies & Servlet of Java

Answer»

The correct option is (C) DataInputStream data = request.getInputStream()

Best explanation: INPUTSTREAM is an ABSTRACT class. getInputStream() RETRIEVES the request in BINARY data.

4.

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 executedThe question was asked in final exam.This intriguing question originated from Servlet topic in portion Java Server Technologies & Servlet of Java

Answer»

Right choice is (a) The destroy() METHOD is CALLED only once at the end of the LIFE CYCLE of a filter

Easiest explanation: destroy() is an end of life cycle method so it is called at the end of life cycle.

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 name)I got this question in homework.I need to ask this question from Servlet in portion Java Server Technologies & Servlet of Java

Answer»

Right CHOICE is (a) SESSION.getAttribute(String name)

Easiest explanation: session has VARIOUS METHODS for use.

6.

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()The question was asked by my school principal while I was bunking the class.This is a very interesting question from Servlet topic in chapter Java Server Technologies & Servlet of Java

Answer»

Correct ANSWER is (a) Request.getISO3Country()

Easiest EXPLANATION: Each country is USUALLY denoted by a 3 DIGIT CODE.ISO3 is the 3 digit country code.

7.

Can servlet class declare constructor with ServletConfig object as an argument?(a) True(b) FalseI have been asked this question in examination.Question is from Servlet topic in section Java Server Technologies & Servlet of Java

Answer»

The correct answer is (b) False

Explanation: SERVLETCONFIG object is CREATED after the constructor is CALLED and before init() is called. So, servlet init PARAMETERS cannot be accessed in the constructor.

8.

How constructor can be used for a servlet?(a) Initialization(b) Constructor function(c) Initialization and Constructor function(d) Setup() methodI have been asked this question in an online quiz.I would like to ask this question from Servlet topic in portion Java Server Technologies & Servlet of Java

Answer»

Correct answer is (c) Initialization and CONSTRUCTOR function

Easy explanation: We cannot declare constructors for interface in Java. This means we cannot ENFORCE this REQUIREMENT to any CLASS which implements Servlet interface.

Also, Servlet requires ServletConfig object for initialization which is created by container.

9.

What happens if IP Address of host cannot be determined?(a) The system exit with no message(b) UnknownHostException is thrown(c) IOException is thrown(d) Temporary IP Address is assignedThis question was addressed to me in a job interview.This intriguing question originated from Client and Server topic in portion Java Server Technologies & Servlet of Java

Answer» RIGHT choice is (b) UnknownHostException is thrown

The explanation: UnknownHostException is thrown when IP ADDRESS of host cannot be DETERMINED. It is an EXTENSION of IOException.
10.

What does local IP address start with?(a) 10.X.X.X(b) 172.X.X.X(c) 192.168.X.X(d) 10.X.X.X, 172.X.X.X, or 192.168.X.XI got this question in an interview for internship.Origin of the question is Client and Server topic in division Java Server Technologies & Servlet of Java

Answer»

The CORRECT answer is (d) 10.X.X.X, 172.X.X.X, or 192.168.X.X

The explanation is: LOCAL IP addresses look LIKE 10.X.X.X, 172.X.X.X, or 192.168.X.X.

11.

Which class represents an Internet Protocol address?(a) InetAddress(b) Address(c) IP Address(d) TCP AddressI had been asked this question in homework.This key question is from Client and Server in division Java Server Technologies & Servlet of Java

Answer»

Right ANSWER is (a) InetAddress

The explanation is: InetAddress represents an INTERNET PROTOCOL ADDRESS. It provides STATIC methods like getByAddress(), getByName() and other instance methods like getHostName(), getHostAddress(), getLocalHost().

12.

Which of the below are common network protocols?(a) TCP(b) UDP(c) TCP and UDP(d) CNPI have been asked this question by my school principal while I was bunking the class.This intriguing question comes from Client and Server topic in portion Java Server Technologies & Servlet of Java

Answer»

The correct choice is (c) TCP and UDP

To explain: Transmission Control Protocol(TCP) and User Datagram Protocol(UDP) are the TWO COMMON network protocol. TCP/IP ALLOWS RELIABLE communication between two applications. UDP is connection LESS protocol.

13.

Which class provides system independent server side implementation?(a) Socket(b) ServerSocket(c) Server(d) ServerReaderThis question was addressed to me during an interview.I'd like to ask this question from Client and Server topic in division Java Server Technologies & Servlet of Java

Answer» CORRECT answer is (b) ServerSocket

To explain I would say: ServerSocket is a java.net class which provides system independent IMPLEMENTATION of server SIDE SOCKET connection.
14.

What does bind() method of ServerSocket offer?(a) binds the serversocket to a specific address (IP Address and port)(b) binds the server and client browser(c) binds the server socket to the JVM(d) binds the port to the JVMI got this question in a national level competition.Question is taken from Client and Server in portion Java Server Technologies & Servlet of Java

Answer»

The correct choice is (a) BINDS the serversocket to a specific address (IP Address and port)

EXPLANATION: bind() binds the server socket to a specific address (IP Address and port). If address is null, the system will pick an ephemeral port and VALID LOCAL address to bind socket.

15.

What happens if ServerSocket is not able to listen on the specified port?(a) The system exits gracefully with appropriate message(b) The system will wait till port is free(c) IOException is thrown when opening the socket(d) PortOccupiedException is thrownThe question was asked in an international level competition.Query is from Client and Server in section Java Server Technologies & Servlet of Java

Answer»

The correct ANSWER is (c) IOException is thrown when opening the socket

The best I can EXPLAIN: public SERVERSOCKET() CREATES an unbound server socket. It throws IOException if specified port is busy when opening the socket.

16.

In CGI, process starts with each request and will initiate OS level process.(a) True(b) FalseThis question was posed to me in unit test.I want to ask this question from Client and Server topic in division Java Server Technologies & Servlet of Java

Answer»

Right option is (a) True

To ELABORATE: A NEW process is started with each CLIENT request and that corresponds to initiate a heavy OS LEVEL process for each client request.

17.

How does applet and servlet communicate?(a) HTTP(b) HTTPS(c) FTP(d) HTTP TunnelingI have been asked this question during a job interview.The origin of the question is Client and Server topic in section Java Server Technologies & Servlet of Java

Answer» RIGHT choice is (d) HTTP Tunneling

To explain I WOULD say: APPLET and SERVLET communicate through HTTP Tunneling.
18.

What does MIME stand for?(a) Multipurpose Internet Messaging Extension(b) Multipurpose Internet Mail Extension(c) Multipurpose Internet Media Extension(d) Multipurpose Internet Mass ExtensionI got this question in homework.The question is from Web application topic in portion Java Server Technologies & Servlet of Java

Answer»

The correct choice is (B) Multipurpose INTERNET MAIL Extension

To elaborate: MIME is an acronym for Multi-purpose Internet Mail Extensions. It is used for classifying FILE types over the Internet. It contains type/subtype e.g. application/msword.

19.

Which of the below can be used to debug front end of a web application?(a) Junit(b) Fitnesse(c) Firebug(d) MockitoI have been asked this question in an internship interview.I need to ask this question from Web application in division Java Server Technologies & Servlet of Java

Answer»

Correct CHOICE is (c) FIREBUG

For explanation I would say: Firebug integrates with firefox and ENABLES to edit, DEBUG and MONITOR CSS, HTML and javascript of any web page.

20.

Which of the below is not a javascript framework for UI?(a) Vaadin(b) AngularJS(c) KendoUI(d) SpringcoreI got this question in an interview for internship.This is a very interesting question from Web application in chapter Java Server Technologies & Servlet of Java

Answer»

Correct answer is (d) Springcore

For EXPLANATION I would say: Springcore is not a javascript framework. It is a comprehensive PROGRAMMING and CONFIGURATION model for enterprise applications based on java.

21.

What type of protocol is HTTP?(a) stateless(b) stateful(c) transfer protocol(d) information protocolThis question was posed to me by my school principal while I was bunking the class.The question is from Web application topic in division Java Server Technologies & Servlet of Java

Answer»

Correct choice is (a) STATELESS

To explain I would say: HTTP is a stateless protocol. It works on request and response MECHANISM and each request is an INDEPENDENT TRANSACTION.

22.

How can we take input text from user in HTML page?(a) input tag(b) inoutBufferedReader tag(c) meta tag(d) scanner tagThe question was posed to me in an internship interview.My question is based upon Web application topic in division Java Server Technologies & Servlet of Java

Answer»

Right OPTION is (a) INPUT tag

Easy explanation: HTML provides various user input OPTIONS LIKE input, radio, text, etc.

23.

How can we connect to database in a web application?(a) oracle sql developer(b) toad(c) JDBC template(d) mysqlThis question was posed to me in an online quiz.The above asked question is from Web application in division Java Server Technologies & Servlet of Java

Answer» CORRECT option is (C) JDBC template

Easy explanation: JDBC template can be USED to connect to database and fire QUERIES against it.
24.

Which component can be used for sending messages from one application to another?(a) server(b) client(c) mq(d) webappThis question was addressed to me during an interview for a job.This intriguing question comes from Web application in chapter Java Server Technologies & Servlet of Java

Answer»

The CORRECT answer is (C) mq

To elaborate: Messaging is a method of communication between software components or APPLICATIONS. MQ can be USED for passing message from sender to receiver.

25.

How are java web applications packaged?(a) jar(b) war(c) zip(d) both jar and warThe question was posed to me during an online interview.My doubt stems from Web application topic in division Java Server Technologies & Servlet of Java

Answer»

Correct option is (d) both jar and war

To explain I would SAY: war are deployed on apache servers or TOMCAT servers. With Spring boot and few other TECHNOLOGIES tomcat is BROUGHT on the machine by deploying jar.

26.

Which perspective is used to run a program in debug view?(a) java perspective(b) eclipse perspective(c) debug perspective(d) jdbc perspectiveThis question was posed to me during an internship interview.The origin of the question is Debugging in Eclipse topic in chapter Java Server Technologies & Servlet of Java

Answer» RIGHT OPTION is (c) debug perspective

The explanation: We can SWITCH from one perspective to another. Debug perspective shows US the breakpoints, VARIABLES, etc.
27.

Servlet are used to program which component in a web application?(a) client(b) server(c) tomcat(d) appletThe question was posed to me in an international level competition.My enquiry is from Web application topic in portion Java Server Technologies & Servlet of Java

Answer»

Correct ANSWER is (B) server

To EXPLAIN: A servlet class extends the capabilities of servers that host applications which are ACCESSED by way of a request-response programming model.

28.

What happens when the value of variable change?(a) changed value pop on the screen(b) variable changes are printed in logs(c) dump of variable changes are printed on the screen on end of execution(d) variable tab shows variables highlighted when values changeThis question was addressed to me in quiz.My doubt is from Debugging in Eclipse topic in division Java Server Technologies & Servlet of Java

Answer»

Correct CHOICE is (d) variable TAB shows variables highlighted when values change

To explain: When a variable value CHANGES, the value in variable tab is highlighted YELLOW in ECLIPSE.

29.

What is debugging an application which runs on another java virtual machine on another machine?(a) virtual debugging(b) remote debugging(c) machine debugging(d) compiling debuggingThis question was posed to me in unit test.This interesting question is from Debugging in Eclipse topic in portion Java Server Technologies & Servlet of Java

Answer»

Right OPTION is (b) remote debugging

The best I can explain: Remote debugging ALLOWS us to debug applications which run on ANOTHER Java virtual MACHINE or even on another machine. We need to set certain flags while starting the APPLICATION.

30.

Which view allows us to delete and deactivate breakpoints and watchpoints?(a) breakpoint view(b) variable view(c) debug view(d) logger viewI have been asked this question in an online interview.Origin of the question is Debugging in Eclipse in section Java Server Technologies & Servlet of Java

Answer»

Right ANSWER is (a) breakpoint view

To EXPLAIN: The Breakpoints view allows US to delete and deactivate breakpoints and watchpoints. We can ALSO MODIFY their properties.

31.

Which key helps to step out of the caller of currently executed method?(a) F3(b) F5(c) F7(d) F8I got this question in my homework.I would like to ask this question from Debugging in Eclipse in chapter Java Server Technologies & Servlet of Java

Answer» CORRECT choice is (c) F7

To ELABORATE: F7 STEPS out to the caller of the currently executed method. This finishes the execution of the current method and RETURNS to the caller of this method.
32.

How to deep dive into the execution of a method from a method call?(a) F3(b) F5(c) F7(d) F8I got this question in unit test.I need to ask this question from Debugging in Eclipse in division Java Server Technologies & Servlet of Java

Answer»

Right answer is (b) F5

To explain I WOULD say: F5 EXECUTES currently selected line and goes to the NEXT line in the program. If the selected line is a method call, debugger steps into the associated CODE.

33.

How can we move from one desired step to another step?(a) breakpoints(b) System.out.println(c) logger.log(d) logger.errorThis question was posed to me in an interview for internship.This intriguing question comes from Debugging in Eclipse topic in division Java Server Technologies & Servlet of Java

Answer»

The correct answer is (a) BREAKPOINTS

For explanation: Breakpoints are inserted in code. We can MOVE from ONE point to ANOTHER in the EXECUTION of a program.

34.

Which part stores the program arguments and startup parameters?(a) debug configuration(b) run configuration(c) launch configuration(d) project configurationI have been asked this question during an interview.I need to ask this question from Debugging in Eclipse in division Java Server Technologies & Servlet of Java

Answer»

The correct choice is (c) launch CONFIGURATION

The explanation is: Launch configuration STORES the STARTUP class, program arguments and vm arguments.

35.

Which mode allows us to run program interactively while watching source code and variables during execution?(a) safe mode(b) debug mode(c) successfully run mode(d) exception modeThis question was addressed to me during an online interview.Asked question is from Debugging in Eclipse in section Java Server Technologies & Servlet of Java

Answer»

Right option is (b) DEBUG MODE

The explanation: Debug mode allows us to RUN PROGRAM interactively while watching source code and variables during execution.