In the name of ALLAH, the most beneficient, the most merciful

Web Design and Development (CS506)

Multiple Choice Questions (MCQs)

 

Objective Questions

Question

To define the error page in JSP we use following tag?

  1. exception-type
  2. error-type
  3. error-page
  4. exception-page

Answer: 3 Chapter No. 39 

Question

From the following methods, which method cannot be overridden in the JSP page

  1. _jspService()
  2. jspDestroy()
  3. jspInit()
  4. None of the given

Answer: 1 Chapter No. 35 

Question

From the following which one is not a JSP directive?

  1. page
  2. include
  3. taglib
  4. out

Answer: 4 Chapter No. 35 

Question

From following which one is the object of JspWriter used to send output to the client.

  1. request
  2. out
  3. response
  4. None of these

Answer: 2 Chapter No. 35 

Question

From following tags, which one is the Special JSP tag?

  1. <%! %>
  2. <%= %>
  3. <%@ %>

Answer: 1 Chapter No. 34 

Question

HTML form data can be processed by JSP

  1. True
  2. False

Answer: 1 Chapter No. 34 

Question

From following which code can be used to create session object in the Servlet:

  1. HttpSession session = req.getSession(true);
  2. HttpSession session = req.getSession(false);
  3. HttpSession session = req.getSession(1);
  4. None of the given

Answer: 1 Chapter No. 32 

Question

A cookie is a piece of _________ that a web server can store on a client’s hard disk.

  1. Text
  2. Number
  3. String
  4. None of these

Answer: 1 Chapter No. 31 

Question

Session Tracking is done through following techniques?

  1. Cookies
  2. Hidden fields
  3. URL Rewriting
  4. All the these

Answer: 4 Chapter No. 31 

Question

Session tracking is referred as

  1. Record maintenance of user status
  2. Record maintenance of the server
  3. Record maintenance of the client
  4. Observing security issues

Answer: 1 Chapter No. 30 

Question

Which of the following object contains information specific to a servlet?

  1. ServletContext
  2. ServletConfig
  3. ServletRequest
  4. ServletResponse

Answer: 2 Chapter No. 29 

Question

Which of the following object is used for sharing resources among different servlets of same application?

  1. ServletConfig
  2. ServletRequest
  3. ServletResponse
  4. ServletContext

Answer: 4 Chapter No. 29 

Question

Which of the following method is called only once during life cycle of Servlet?

  1. service()
  2. init()
  3. destroy()
  4. start()

Answer: 2 Chapter No. 28 

Question

getParameters() method returns an array of strings containing the values for a specified servlet parameter.

  1. True
  2. False

Answer: 2 Chapter No. 28 

Question

Servlet mapping is defined in ________.

  1. servlet
  2. web.xml
  3. html
  4. JSP

Answer: 2 Chapter No. 27 

Question

Web.xml is a ___________

  1. java file
  2. configuration file
  3. jar file
  4. servlet

Answer: 2 Chapter No. 27 

Question

Which of the following Environment variable tells the system about the root directory of TOMCAT?

  1. JAva_HOME
  2. CATALINA_HOME
  3. CLASSPATH
  4. PATH

Answer: 2 Chapter No. 26 

Question

Which of the following range of response code indicates that request was successful?

  1. 100-199
  2. 200-299
  3. 300-399
  4. 400-499

Answer: 2 Chapter No. 25 

Question

Servlets are used to

  1. Create graphics
  2. Provide dynamic web contents which extend web servers
  3. Develop applets
  4. Create GUI

Answer: 2 Chapter No. 25 

Question

Which of the following method call causes the currently executing thread to return to Ready state?

  1. sleep()
  2. yield()
  3. wait()
  4. None of the given

Answer: 1 Chapter No. 24 

Question

Which of the following methods are invoked by the AWT to support paint and repaint operations?

  1. paint( )
  2. repaint( )
  3. draw( )
  4. redraw( )

Answer: 1 Chapter No. 19 

Question

Which of the following object is passed as an argument to paintComponent() method?

  1. Image object
  2. JPanel object
  3. JFrame object
  4. Graphics object

Answer: 4 Chapter No. 18 

Question

isReadOnly() is a method of _________ object.

  1. ResultSet
  2. ResultSetMetaData
  3. DataBaseMetaData
  4. Connection

Answer: 3 Chapter No. 17 

Question

Which of the following syntax is used to get ResultSetMetaData object?

  1. None of the given
  2. ResultSetMetaData md = rs.getMetaData();
    // where rs is ResultSet object
  3. ResultSetMetaData md = st.getMetaData();
    // where st is Statement object
  4. ResultSet md = rs.getMetaData();
    // where rs is ResultSetMetaData object

Answer: 2 Chapter No. 17 

Question

Which of the following is NOT a method of ResultSet object?

  1. next()
  2. absolute(int)
  3. executeQuery(sql)
  4. updateRow()

Answer: 3 Chapter No. 16 

Question

previous() is a method of __________ object.

  1. Statement
  2. ResultSet
  3. ResultSetMetaData
  4. Connection

Answer: 2 Chapter No. 16 

Question

Which of the following statement object is used to execute simple SQL statement?

  1. Statement
  2. PreparedStatement
  3. CallableStatement
  4. None of the given

Answer: 1 Chapter No. 15 

Question

Which of the following statement object is used to execute stored procedures?

  1. Statement
  2. PreparedStatement
  3. CallableStatement
  4. None of the given

Answer: 3 Chapter No. 15 

Question

Java defines _________ for the listener interfaces having more than one event handling methods.

  1. Wrapper classes
  2. Abstract classes
  3. Concrete classes
  4. Adapter classes

Answer: 4 Chapter No. 13 

Question

WindowListener interface contains __________ methods.

  1. Four
  2. Six
  3. Seven
  4. Eight

Answer: 3 Chapter No. 12 

Question

Which of the following function will be used to register event handler with events generator (button)?

  1. addAction()
  2. addActionListener()
  3. addListener()
  4. None of the given

Answer: 2 Chapter No. 11 

Question

If a class needs to handle events generated by button then which of the following interface a class needs to implement?

  1. ComponentListener
  2. KeyListener
  3. MouseListener
  4. ActionListener

Answer: 4 Chapter No. 11 

Question

JPanel and Applet use _________ as their default layout.

  1. Flow layout
  2. Border layout
  3. Grid layout
  4. GridBag layout

Answer: 3 Chapter No. 10 

Question

Which of the following is a top level container?

  1. JPanel
  2. ToolBar
  3. ScrollPane
  4. Dialog

Answer: 4 Chapter No. 10 

Question

Which of the following is called "pure abstract class"?

  1. Concrete class
  2. Wrapper class
  3. Interface
  4. Abstract class with no abstract method

Answer: 1 Chapter No. 9 

Question

The relationship between class and interface is called __________.

  1. Is a' relationship
  2. Has a' relationship
  3. Responds to' relationship
  4. None of the given

Answer: 3 Chapter No. 9 

Question

An instance of abstract class cannot be created.

  1. True
  2. False

Answer: 1 Chapter No. 9 

Question

Which of the following syntax attaches an output stream to console?

  1. FileWriter fw = new FileWriter(“output.txt”);
  2. FileWriter fw = new FileWriter(FileDescriptor.out);
  3. FileWriter fw = new FileWriter(FileDescriptor.in);
  4. FileWriter fw = new FileWriter(FileDescriptor);

Answer: 1 Chapter No. 8 

Question

Based on functionality, the streams can be categorized as ________

  1. Byte oriented stream and Node stream
  2. Filter stream and Character oriented stream
  3. Node stream and Filter stream
  4. Byte oriented stream and Character oriented stream

Answer: 3 Chapter No. 8 

Question

Which of the following stream read/write data in the form of bytes?

  1. FileReader
  2. FileWriter
  3. PrintWriter
  4. FileInputStream

Answer: 4 Chapter No. 8 

Question

Which of the following stream is a Node stream?

  1. PrintWriter
  2. FileWriter
  3. BufferedReader
  4. All of the given.

Answer: 2 Chapter No. 8 

Question

Which of the following syntax is used to attach an input stream to console?

  1. FileReader fr = new FileReader(“input.txt”);
  2. FileReader fr = new FileReader(FileDescriptor.in);
  3. FileReader fr = new FileReader(FileDescriptor);
  4. FileReader fr = new FileReader(console);

Answer: 1 Chapter No. 8 

Question

Which of the following package needs to be import while handling files?

  1. java.util
  2. java.io
  3. java.awt
  4. javax.swing

Answer: 2 Chapter No. 7 

Question

When defining a method you must include a ___________ to declare any exception that might be thrown but is not caught in the method.

  1. try block
  2. finally block
  3. catch block
  4. throws-clause

Answer: 4 Chapter No. 7 

Question

Aside from the Scanner class, which of the following classes can be used for text-file input?

  1. ObjectInputStream
  2. BufferedReader
  3. StringTokenizer
  4. None of the given

Answer: 2 Chapter No. 7 

Question

HahMap takes key as a/an _________

  1. Object
  2. Array
  3. Primitive value
  4. Function

Answer: 1 Chapter No. 6 

Question

A collection can store _________

  1. Homogenous objects
  2. Heterogeneous objects
  3. Objects as well as primitive values
  4. At most 100 objects

Answer: 2 Chapter No. 6 

Question

The collection API are defined in _______ package.

  1. java.io
  2. java.util
  3. java.awt
  4. java.sql

Answer: 2 Chapter No. 6 

Question

Which of the following is used for inheritance in java?

  1. implements
  2. extends
  3. : (colon)
  4. inherit

Answer: 2 Chapter No. 5 

Question

If a super class method is protected then overriding method _________

  1. must be protected
  2. must be public
  3. must be private
  4. may be either protected or public

Answer: 4 Chapter No. 5 

Question

A variable declared as static in a class is a/an _________

  1. Instance variable
  2. Class variable
  3. Const variable
  4. Global variable

Answer: 2 Chapter No. 4 

Question

The toString () method returns a _________ representation of _______

  1. int, string
  2. string, int
  3. string, object
  4. object, string

Answer: 3 Chapter No. 4 

Question

What will happen if static modifier is removed from the signature of main method?

  1. The program does not compile
  2. The program compiles and runs successfully
  3. The program compiles but does not run
  4. None of the given

Answer: 3 Chapter No. 2 

Question

What will happen if main method is declared as private?

  1. The program does not compile
  2. The program throws an exception at run time
  3. The program compiles and runs successfully
  4. None of the given

Answer: 2 Chapter No. 2 

Question

If we remove static from main then program _______

  1. Program cannot compile
  2. Program will compile and work properly
  3. Run time errors
  4. Exception throws in main

Answer: 4 Chapter No. 2 

Question

If we remove String array from main then program_______

  1. Program cannot compile
  2. Program will compile and work properly
  3. Run time errors
  4. Exception throws in main

Answer: 4 Chapter No. 2 

Question

Java developed in ________

  1. 1990
  2. 1995
  3. 1997
  4. 2000

Answer: 2 Chapter No. 1 

Question

An event in java is represented as ________

  1. Operator
  2. Function
  3. Object
  4. Primitive data type

Answer: Chapter No.  

Question

From the following indicators; which is added in user session to know the session time out?

  1. Sessiontimeoutindicator
  2. SessionTimeOutIndicator
  3. SessionTimeoutIndicator
  4. None of these

Answer: 3 Chapter No.  

Question

What will happen if the String array is not provided as an argument to main method?

  1. The program does not compile
  2. The program compiles but does not run
  3. The program compiles and runs successfully
  4. None of the given.

Answer: 3 Chapter No.  

Question

Why we use RequestDispatcher to forward a request to another resource(servlet, html, jsp), instead of using a sendRedirect()?

  1. sendRedirect() is not supported in servlet API
  2. RequestDispatcher is not supported in servlet API
  3. RequestDispatcher is efficient and allows the server to maintain request status
  4. None of these

Answer: Chapter No.  

Question

From the following packages which one is used to write the servlets?

  1. javax
  2. java
  3. java.util
  4. java.lang

Answer: 1 Chapter No.  

Question

Interface can be implemented in JSP

  1. True
  2. False

Answer: 2 Chapter No.  

Question

Is it possible to provide more than one main method within same class?

  1. True
  2. False

Answer: Chapter No.  

Question

Java program code is compiled into a form called _______.

  1. Machine code
  2. Byte code
  3. Native code
  4. Source code

Answer: Chapter No.  

Question

javax.servlet.jsp.PageContext, is used to give a __________ point of access to many of the page attributes.

  1. Single
  2. Multiple

Answer: 1 Chapter No.  

Question

JSP comments are declared through following tag

  1. <%@ %>
  2. <%-- --%>
  3. <%! %>
  4. <%= %>

Answer: 2 Chapter No.  

Question

JSP scripting elements is/are

  1. Declarations
  2. Scriptlets
  3. expressions
  4. All of the given.

Answer: 4 Chapter No.  

Question

JSP technology is extensible

  1. True
  2. False

Answer: 1 Chapter No.  

Question

Relationship between JSP and servlets is

  1. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage
  2. JSP and servlets are unrelated technologies
  3. Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The two technologies are not useful in combination
  4. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage

Answer: Chapter No.  

Question

response.sendRedirect(); is a implicit object of response which redirect the browser to the different resource.

  1. True
  2. False

Answer: 1 Chapter No.