Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  Which component can be used for sending messages from one application to another?

a. server

b. client

c. mq

d. webapp


Answer- mq


Que-  How are java web applications packaged?

a. jar

b. war

c. zip

d. both jar and war


Answer- both jar and war


Que-  How can we connect to database in a web application?

a. oracle sql developer

b. toad

c. JDBC template

d. mysql


Answer- JDBC template


Que-  How can we take input text from user in HTML page?

a. input tag

b. inoutBufferedReader tag

c. meta tag

d. scanner tag


Answer- input tag


Que-  Which of the below is not a javascript framework for UI?

a. Vaadin

b. AngularJS

c. KendoUI

d. Springcore


Answer- Springcore


Que-  Which of the below can be used to debug front end of a web application?

a. Junit

b. Fitnesse

c. Firebug

d. Mockito


Answer- Firebug


Que-  What type of protocol is HTTP?

a. stateless

b. stateful

c. transfer protocol

d. information protocol


Answer- stateless


Que-  What does MIME stand for?

a. Multipurpose Internet Messaging Extension

b. Multipurpose Internet Mail Extension

c. Multipurpose Internet Media Extension

d. Multipurpose Internet Mass Extension


Answer- Multipurpose Internet Mail Extension


Que-  What is the storage capacity of single cookie?

a. 2048 MB

b. 2048 bytes

c. 4095 bytes

d. 4095 MB


Answer- 4095 bytes


Que-  How does applet and servlet communicate?

a. HTTP

b. HTTPS

c. FTP

d. HTTP Tunneling


Answer- HTTP Tunneling


Que-  In CGI, process starts with each request and will initiate OS level process.

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  Which class provides system independent server side implementation?

a. Socket

b. ServerSocket

c. Server

d. ServerReader


Answer- ServerSocket


Que-  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 thrown


Answer- IOException is thrown when opening the socket


Que-  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 JVM


Answer- binds the serversocket to a specific address (IP Address and port)


Que-  Which of the below are common network protocols?

a. TCP

b. UDP

c. TCP and UDP

d. CNP


Answer- TCP and UDP


Que-  Which class represents an Internet Protocol address?

a. InetAddress

b. Address

c. IP Address

d. TCP Address


Answer- InetAddress


Que-  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.X


Answer- 10.X.X.X, 172.X.X.X, or 192.168.X.X


Que-  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 assigned


Answer- UnknownHostException is thrown


Que-  What is the java method for ping?

a. hostReachable()

b. ping()

c. isReachable()

d. portBusy()


Answer- isReachable()


Que-  How constructor can be used for a servlet?

a. Initialization

b. Constructor function

c. Initialization and Constructor function

d. Setup() method


Answer- Initialization and Constructor function


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

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-FALSE


Que-  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- session.getAttribute(String name)


Que-  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- Request.getISO3Country()


Que-  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- DataInputStream data = request.getInputStream()


Que-  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- The destroy() method is called only once at the end of the life cycle of a filter


Que-  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- Servlets execute within the address space of web server, platform independent and uses the functionality of java class libraries


Que-  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- servlet filter


Que-  Which of the following is used for session migration?

a. Persisting the session in database

b. URL rewriting

c. Create new database connection

d. Kill session from multiple sessions


Answer- Persisting the session in database


Que-  Which of the below is not a session tracking method?

a. URL rewriting

b. History

c. Cookies

d. SSL sessions


Answer- History


Que-  Which of the following is stored at client side?

a. URL rewriting

b. Hidden form fields

c. SSL sessions

d. Cookies


Answer- Cookies


Que-  Which of the following leads to high network traffic?

a. URL rewriting

b. Hidden form fields

c. SSL sessions

d. Cookies


Answer- URL rewriting


Que-  Which of the following is not true about session?

a. All users connect to the same session

b. All users have same session variable

c. Default timeout value for session variable is 20 minutes

d. New session cannot be created for a new user


Answer- Default timeout value for session variable is 20 minutes


Que-  SessionIDs are stored in cookies.

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  What is the maximum size of cookie?

a. 4 KB

b. 4 MB

c. 4 bytes

d. 40 KB


Answer- 4 KB


Que-  How can we invalidate a session?

a. session.discontinue()

b. session.invalidate()

c. session.disconnect()

d. session.falsify()


Answer- session.invalidate()


Que-  Which method creates unique fields in the HTML which are not shown to the user?

a. User authentication

b. URL writing

c. HTML Hidden field

d. HTML invisible field


Answer- HTML Hidden field


Que-  Which object is used by spring for authentication?

a. ContextHolder

b. SecurityHolder

c. AnonymousHolder

d. SecurityContextHolder


Answer- SecurityContextHolder


Que-  Which page directive should be used in JSP to generate a PDF page?

a. contentType

b. generatePdf

c. typePDF

d. contentPDF


Answer- contentType


Que-  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- Using <%jsp:page> tag


Que-  Application is instance of which class?

a. javax.servlet.Application

b. javax.servlet.HttpContext

c. javax.servlet.Context

d. javax.servlet.ServletContext


Answer- javax.servlet.ServletContext


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

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  Which option is true about session scope?

a. Objects are accessible only from the page in which they are created

b. Objects are accessible only from the pages which are in same session

c. Objects are accessible only from the pages which are processing the same request

d. Objects are accessible only from the pages which reside in same application


Answer- Objects are accessible only from the pages which are in same session


Que-  Default value of autoFlush attribute is?

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  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- Compilation, Initialization, Execution, Cleanup


Que-  "request" is instance of which one of the following classes?

a. Request

b. HttpRequest

c. HttpServletRequest

d. ServletRequest


Answer- HttpServletRequest


Que-  Which is not a directive?

a. include

b. page

c. export

d. useBean


Answer- export


Que-  Which is mandatory in <jsp:useBean /> tag?

a. id, class

b. id, type

c. type, property

d. type,id


Answer- id, class

Previous Post Next Post