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

Web Design and Development (CS506)

Multiple Choice Questions (MCQs)

Objective Questions

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

    1. exception-type
    2. error-type
    3. error-page
    4. exception-page
  2. 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
  3. From the following methods, which method cannot be overridden in the JSP page

    1. _jspService()
    2. jspDestroy()
    3. jspInit()
    4. None of the given
  4. From the following which one is not a JSP directive?

    1. page
    2. include
    3. taglib
    4. out
  5. HTML form data can be processed by JSP

    1. True
    2. False
  6. From following tags, which one is the Special JSP tag?

    1. <jsp: .…. />
    2. <%! %>
    3. <%= %>
    4. <%@ %>
  7. 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
  8. 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
  9. Session Tracking is done through following techniques?

    1. Cookies
    2. Hidden fields
    3. URL Rewriting
    4. All the these
  10. 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
  11. Which of the following object contains information specific to a servlet?

    1. ServletContext
    2. ServletConfig
    3. ServletRequest
    4. ServletResponse
  12. Which of the following object is used for sharing resources among different servlets of same application?

    1. ServletConfig
    2. ServletRequest
    3. ServletResponse
    4. ServletContext
  13. Which of the following method is called only once during life cycle of Servlet?

    1. service()
    2. init()
    3. destroy()
    4. start()
  14. getParameters() method returns an array of strings containing the values for a specified servlet parameter.

    1. True
    2. False
  15. Servlet mapping is defined in ________.

    1. servlet
    2. web.xml
    3. html
    4. JSP
  16. Web.xml is a ___________

    1. java file
    2. configuration file
    3. jar file
    4. servlet
  17. 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
  18. 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
  19. Servlets are used to

    1. Create graphics
    2. Provide dynamic web contents which extend web servers
    3. Develop applets
    4. Create GUI
  20. 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
  21. An error JSP is called by the web server when an uncaught exception gets occurred.

    1. True
    2. False
  22. Which of the following is the main idea behind partitioning a web application into layers?

    1. Increase Coupling
    2. Reduce Coupling
    3. Increase Decoupling
    4. Reduce Decoupling
  23. There is NO equivalent tag for comments while writing JSP scripting element in XML.

    1. True
    2. False
  24. In context of JSP custom tags, is it true that a "Tag with Body" must have one or more attributes?

    1. True
    2. False
  25. The method "getAttribute(String)" of HttpSession class extracts ________ stored value from a session object.

    1. Subsequently
    2. Currently
    3. Previously
    4. First
  26. In a JavaBean class, private vlues should be accessed through setters/getters.

    1. True
    2. False
  27. Packages are nothing more than the way we organize files into different directories according to their functionality, usability as well as category they should belong to:

    1. True
    2. False
  28. Which of the following is the correct format of writing an include directive in JSP?

    1. <%! include {attribute="val"} %>
    2. <%@ include {attribute="val"}%>
    3. <%# include {attribute="val"} %>
    4. <%$ include {attribute="val"} %>
  29. 3-layer architecture consists of Presentation Layer, ________ Layer and Data layer.

    1. Application
    2. Business
    3. Server
    4. Client
  30. Which one of the following is wrong while appending parameters trough url?
    Original url: http://www.abc.com:1125/servlet/pics

    1. http://www.abc.com:1125/servlet/pics/123
    2. http://www.abc.com:1125/servlet/pics?id=123
    3. http://www.abc.com:1125/servlet/pics?id(123)
    4. http://www.abc.com:1125/servlet/rewrite:$id$123
  31. Which of the following approach is also called page-with-bean approach.

    1. Page-Centric approach
    2. MVC Model1
    3. MVC Model2
    4. MVC Model3
  32. A JavaBean class must have a zero argument constructor.

    1. True
    2. False
  33. JSP forward action element is used to include files at request time.

    1. True
    2. False
  34. In the context of JSP expressions and scriptlets, pageDirective is NOT an implicit object.

    1. True
    2. False
  35. The correct way to define a JSP include action element is:

    1. <jsp:include page @"one.jsp"/>
    2. <jsp:include page = "one.jsp"/>
    3. <jsp:include page #"one.jsp"/>
    4. <jsp:include page $ "one.jsp"/>
  36. JSp directives are used to convay special processing information about the page to JSP container.

    1. True
    2. False
  37. Java Servlets are NOT automatically swtich to URL Rewriting when cookies are not supported or disaled by the client.

    1. True
    2. False
  38. The correct way to get user's session object is:

    1. HttpSession httpSession = request.getSession(true);
    2. ClientSession ClientSession = request.getSession(true);
    3. HttpSession httpSession = response.getSession(true);
    4. ClientSession ClientSession = response.getSession(true);
  39. Which of the given option is NOT true for Page-centric approach?

    1. A lot of code is also get duplicated
    2. The Maintenance of the application becomes a nightmare
    3. The code becomes a mixture of presentation, business and data access logic
    4. Scaling of such kind of application is easy
  40. Is it true that a JavaBean class can have any public instance variables/attributes?

    1. Yes
    2. No
  41. The correct way to declare a page as an error page in JSP is:

    1. < %@page ... errorPage = "true"%>
    2. < %@page ... isErrorPage = "true"%>
    3. < %@page ... setErrorPage = "true"%>
    4. < %@page ... getErrorPage = "true"%>
  42. Presence of cookie indicates that the user is visiting this site for first time.

    1. True
    2. False
  43. Which of the following is the correct format of writing a page directive in JSP?

    1. <%! Page{attribte="val"} %>
    2. <%@ Page{attribte="val"} %>
    3. <%# Page{attribte="val"} %>
    4. <%$ Page{attribte="val"} %>
  44. Layers are isolated from each other to increase coupling between them.

    1. True
    2. False
  45. Session Tracking is NOT done through the following technique?

    1. Cookies
    2. Hidden fields
    3. Url Rewriting
    4. Session Object
  46. In JSP scripting elements, it is NOT necessary that every opening tag also have a closing tag.

    1. True
    2. False
  47. Is it true that a JavaBean class CAN NOT be easily reused and composed together in an application?

    1. Yes
    2. No
  48. Is it true that Enterprise Applications need to support multiple types of users with multiple types of interfaces?

    1. Yes
    2. No
  49. A layer represents the ________ view of application.

    1. Biological
    2. Logical
    3. Local
    4. Physical
  50. Which of the following information is required by the JSP container?

    1. JSP version
    2. Tag name
    3. Tag library version
    4. All of the given.
  51. A Tier represents the ________ view of application.

    1. Logical
    2. Biological
    3. Physical
    4. Local
  52. Which of the following methods are invoked by the AWT to support paint and repaint operations?

    1. paint( )
    2. repaint( )
    3. draw( )
    4. redraw( )
  53. 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
  54. isReadOnly() is a method of _________ object.

    1. ResultSet
    2. ResultSetMetaData
    3. DataBaseMetaData
    4. Connection
  55. 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
  56. Which of the following is NOT a method of ResultSet object?

    1. next()
    2. absolute(int)
    3. executeQuery(sql)
    4. updateRow()
  57. previous() is a method of __________ object.

    1. Statement
    2. ResultSet
    3. ResultSetMetaData
    4. Connection
  58. Which of the following statement object is used to execute simple SQL statement?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  59. Which of the following statement object is used to execute stored procedures?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  60. 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
  61. WindowListener interface contains __________ methods.

    1. Four
    2. Six
    3. Seven
    4. Eight
  62. 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
  63. 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
  64. JPanel and Applet use _________ as their default layout.

    1. Flow layout
    2. Border layout
    3. Grid layout
    4. GridBag layout
  65. Which of the following is a top level container?

    1. JPanel
    2. ToolBar
    3. ScrollPane
    4. Dialog
  66. Which of the following is called "pure abstract class"?

    1. Concrete class
    2. Wrapper class
    3. Interface
    4. Abstract class with no abstract method
  67. 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
  68. An instance of abstract class cannot be created.

    1. True
    2. False
  69. 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);
  70. 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
  71. Which of the following stream read/write data in the form of bytes?

    1. FileReader
    2. FileWriter
    3. PrintWriter
    4. FileInputStream
  72. Which of the following stream is a Node stream?

    1. PrintWriter
    2. FileWriter
    3. BufferedReader
    4. All of the given.
  73. 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);
  74. Which of the following package needs to be import while handling files?

    1. java.util
    2. java.io
    3. java.awt
    4. javax.swing
  75. 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
  76. 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
  77. HahMap takes key as a/an _________

    1. Object
    2. Array
    3. Primitive value
    4. Function
  78. A collection can store _________

    1. Homogenous objects
    2. Heterogeneous objects
    3. Objects as well as primitive values
    4. At most 100 objects
  79. The collection API are defined in _______ package.

    1. java.io
    2. java.util
    3. java.awt
    4. java.sql
  80. 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
  81. Which of the following is used for inheritance in java?

    1. implements
    2. extends
    3. : (colon)
    4. inherit
  82. A variable declared as static in a class is a/an _________

    1. Instance variable
    2. Class variable
    3. Const variable
    4. Global variable
  83. The toString () method returns a _________ representation of _______

    1. int, string
    2. string, int
    3. string, object
    4. object, string
  84. 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
  85. 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
  86. 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
  87. 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
  88. Java developed in ________

    1. 1990
    2. 1995
    3. 1997
    4. 2000
  89. An event in java is represented as ________

    1. Operator
    2. Function
    3. Object
    4. Primitive data type
  90. 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
  91. From the following packages which one is used to write the servlets?

    1. javax
    2. java
    3. java.util
    4. java.lang
  92. Interface can be implemented in JSP

    1. True
    2. False
  93. Is it possible to provide more than one main method within same class?

    1. True
    2. False
  94. Java program code is compiled into a form called _______.

    1. Machine code
    2. Byte code
    3. Native code
    4. Source code
  95. javax.servlet.jsp.PageContext, is used to give a __________ point of access to many of the page attributes.

    1. Single
    2. Multiple
  96. JSP comments are declared through following tag

    1. <%@ %>
    2. <%-- --%>
    3. <%! %>
    4. <%= %>
  97. JSP scripting elements is/are

    1. Declarations
    2. Scriptlets
    3. expressions
    4. All of the given.
  98. JSP technology is extensible

    1. True
    2. False
  99. 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
  100. response.sendRedirect(); is a implicit object of response which redirect the browser to the different resource.

    1. True
    2. False
  101. 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.
  102. 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