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

Web Design and Development (CS506)

Multiple Choice Questions (MCQs)

Objective Questions

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

    1. Concrete class
    2. Wrapper class
    3. Interface
    4. Abstract class with no abstract method
  2. Which of the following statement object is used to execute simple SQL statement?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  3. In the context of JSP expressions and scriptlets, pageDirective is NOT an implicit object.

    1. True
    2. False
  4. Interface can be implemented in JSP

    1. True
    2. False
  5. JSP comments are declared through following tag

    1. <%@ %>
    2. <%-- --%>
    3. <%! %>
    4. <%= %>
  6. 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
  7. Is it true that Enterprise Applications need to support multiple types of users with multiple types of interfaces?

    1. Yes
    2. No
  8. JSP scripting elements is/are

    1. Declarations
    2. Scriptlets
    3. expressions
    4. All of the given.
  9. Which of the following methods are invoked by the AWT to support paint and repaint operations?

    1. paint( )
    2. repaint( )
    3. draw( )
    4. redraw( )
  10. Which of the following method is called only once during life cycle of Servlet?

    1. service()
    2. init()
    3. destroy()
    4. start()
  11. In JSP scripting elements, it is NOT necessary that every opening tag also have a closing tag.

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

    1. Machine code
    2. Byte code
    3. Native code
    4. Source code
  13. 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
  14. 3-layer architecture consists of Presentation Layer, ________ Layer and Data layer.

    1. Application
    2. Business
    3. Server
    4. Client
  15. 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
  16. Which of the following object contains information specific to a servlet?

    1. ServletContext
    2. ServletConfig
    3. ServletRequest
    4. ServletResponse
  17. 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
  18. 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
  19. The method "getAttribute(String)" of HttpSession class extracts ________ stored value from a session object.

    1. Subsequently
    2. Currently
    3. Previously
    4. First
  20. From the following packages which one is used to write the servlets?

    1. javax
    2. java
    3. java.util
    4. java.lang
  21. 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
  22. Which of the following package needs to be import while handling files?

    1. java.util
    2. java.io
    3. java.awt
    4. javax.swing
  23. The collection API are defined in _______ package.

    1. java.io
    2. java.util
    3. java.awt
    4. java.sql
  24. From following tags, which one is the Special JSP tag?

    1. <jsp: .…. />
    2. <%! %>
    3. <%= %>
    4. <%@ %>
  25. From the following methods, which method cannot be overridden in the JSP page

    1. _jspService()
    2. jspDestroy()
    3. jspInit()
    4. None of the given
  26. 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
  27. 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
  28. 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"} %>
  29. 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
  30. 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
  31. 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.
  32. A variable declared as static in a class is a/an _________

    1. Instance variable
    2. Class variable
    3. Const variable
    4. Global variable
  33. 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
  34. 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);
  35. 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
  36. Servlets are used to

    1. Create graphics
    2. Provide dynamic web contents which extend web servers
    3. Develop applets
    4. Create GUI
  37. Session Tracking is done through following techniques?

    1. Cookies
    2. Hidden fields
    3. URL Rewriting
    4. All the these
  38. Is it possible to provide more than one main method within same class?

    1. True
    2. False
  39. Web.xml is a ___________

    1. java file
    2. configuration file
    3. jar file
    4. servlet
  40. An instance of abstract class cannot be created.

    1. True
    2. False
  41. To define the error page in JSP we use following tag?

    1. exception-type
    2. error-type
    3. error-page
    4. exception-page
  42. 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
  43. HahMap takes key as a/an _________

    1. Object
    2. Array
    3. Primitive value
    4. Function
  44. previous() is a method of __________ object.

    1. Statement
    2. ResultSet
    3. ResultSetMetaData
    4. Connection
  45. HTML form data can be processed by JSP

    1. True
    2. False
  46. 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
  47. Is it true that a JavaBean class can have any public instance variables/attributes?

    1. Yes
    2. No
  48. 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
  49. 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"} %>
  50. Layers are isolated from each other to increase coupling between them.

    1. True
    2. False
  51. Presence of cookie indicates that the user is visiting this site for first time.

    1. True
    2. False
  52. JSP technology is extensible

    1. True
    2. False
  53. Which of the following is used for inheritance in java?

    1. implements
    2. extends
    3. : (colon)
    4. inherit
  54. 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
  55. There is NO equivalent tag for comments while writing JSP scripting element in XML.

    1. True
    2. False
  56. 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
  57. Servlet mapping is defined in ________.

    1. servlet
    2. web.xml
    3. html
    4. JSP
  58. 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
  59. WindowListener interface contains __________ methods.

    1. Four
    2. Six
    3. Seven
    4. Eight
  60. 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.
  61. Java Servlets are NOT automatically swtich to URL Rewriting when cookies are not supported or disaled by the client.

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

    1. Yes
    2. No
  63. getParameters() method returns an array of strings containing the values for a specified servlet parameter.

    1. True
    2. False
  64. 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);
  65. 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
  66. From the following which one is not a JSP directive?

    1. page
    2. include
    3. taglib
    4. out
  67. Which of the following stream read/write data in the form of bytes?

    1. FileReader
    2. FileWriter
    3. PrintWriter
    4. FileInputStream
  68. JSP forward action element is used to include files at request time.

    1. True
    2. False
  69. In a JavaBean class, private vlues should be accessed through setters/getters.

    1. True
    2. False
  70. The toString () method returns a _________ representation of _______

    1. int, string
    2. string, int
    3. string, object
    4. object, string
  71. response.sendRedirect(); is a implicit object of response which redirect the browser to the different resource.

    1. True
    2. False
  72. 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"/>
  73. 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
  74. 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
  75. Which of the following is NOT a method of ResultSet object?

    1. next()
    2. absolute(int)
    3. executeQuery(sql)
    4. updateRow()
  76. Which of the following object is used for sharing resources among different servlets of same application?

    1. ServletConfig
    2. ServletRequest
    3. ServletResponse
    4. ServletContext
  77. A Tier represents the ________ view of application.

    1. Logical
    2. Biological
    3. Physical
    4. Local
  78. A collection can store _________

    1. Homogenous objects
    2. Heterogeneous objects
    3. Objects as well as primitive values
    4. At most 100 objects
  79. 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
  80. 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
  81. A layer represents the ________ view of application.

    1. Biological
    2. Logical
    3. Local
    4. Physical
  82. A JavaBean class must have a zero argument constructor.

    1. True
    2. False
  83. 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);
  84. 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
  85. Session Tracking is NOT done through the following technique?

    1. Cookies
    2. Hidden fields
    3. Url Rewriting
    4. Session Object
  86. Which of the following statement object is used to execute stored procedures?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  87. isReadOnly() is a method of _________ object.

    1. ResultSet
    2. ResultSetMetaData
    3. DataBaseMetaData
    4. Connection
  88. Which of the following is a top level container?

    1. JPanel
    2. ToolBar
    3. ScrollPane
    4. Dialog
  89. An error JSP is called by the web server when an uncaught exception gets occurred.

    1. True
    2. False
  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. In context of JSP custom tags, is it true that a "Tag with Body" must have one or more attributes?

    1. True
    2. False
  92. Java developed in ________

    1. 1990
    2. 1995
    3. 1997
    4. 2000
  93. 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
  94. 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
  95. An event in java is represented as ________

    1. Operator
    2. Function
    3. Object
    4. Primitive data type
  96. JSp directives are used to convay special processing information about the page to JSP container.

    1. True
    2. False
  97. JPanel and Applet use _________ as their default layout.

    1. Flow layout
    2. Border layout
    3. Grid layout
    4. GridBag layout
  98. 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"%>
  99. Which of the following stream is a Node stream?

    1. PrintWriter
    2. FileWriter
    3. BufferedReader
    4. All of the given.
  100. 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
  101. javax.servlet.jsp.PageContext, is used to give a __________ point of access to many of the page attributes.

    1. Single
    2. Multiple
  102. 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