Java Web part 2
c) DriverManager
The ______ class is the primary class that has the driver information. Chọn một câu trả lời a) None of the other choices b) Driver c) DriverManager d) ODBCDriver
B. HttpServletResponse
1. The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the one correct answer. A. HttpServletRequest B. HttpServletResponse C. ServletConfig D. ServletContext
A. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext. C. The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method
11. Which of the following are correct statements? Select the two correct answers. A. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext. B. The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server. C. The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method D. The getNamedDispatcher(String) defined in HttpServletRequest class takes the name of the servlet and returns an object of RequestDispatcher class.
A. GET method
12. A user types the URL http://www.javaprepare.com/scwd/index.html . Which HTTP request gets generated. Select the one correct answer. A. GET method B. POST method C. HEAD method D. PUT method
A. GET method
13. Which HTTP method gets invoked when a user clicks on a link? Select the one correct answer. A. GET method B. POST method C. HEAD method D. PUT method
D. POST method sends data in the body of the request.
14. When using HTML forms which of the folowing is true for POST method? Select the one correct answer. A. POST allows users to bookmark URLs with parameters. B. The POST method should not be used when large amount of data needs to be transferred. C. POST allows secure data transmission over the http method. D. POST method sends data in the body of the request.
B. TRACE method
17. Name the http method that sends the same response as the request. Select the one correct answer. A. DEBUG method B. TRACE method C. OPTIONS method D. HEAD method
C. Codes starting from 400
18. Which three digit error codes represent an error in request from client? Select the one correct answer. A. Codes starting from 200 B. Codes starting from 300 C. Codes starting from 400 D. Codes starting from 500
C. /WEB-INF/classes
19. Name the location of compiled class files within a war file? Select the one correct answer. A. /META-INF/classes B. /classes C. /WEB-INF/classes D. /root/classes
B. setContent
2. Name the method defined in the HttpServletResponse class that may be used to set the content type. Select the one correct answer. A. setType B. setContent C. setContentType D. setResponseContentType
D. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method.
3. Which of the following statement is correct. Select the one correct answer. A. The response from the dedicated server to a HEAD request consists of status line, content type and the document. B. The response from the server to a GET request does not contain a document. C. The setStatus method defined in the HttpServletRequest class takes an int as an argument and sets the status of Http response D. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method.
C. SC_NOT_FOUND
4. The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter. Select the one correct answer. A. SC_OK B. SC_MOVED_TEMPORARILY C. SC_NOT_FOUND D. SC_INTERNAL_SERVER_ERROR E. ESC_BAD_REQUEST
B. SC_MOVED_TEMPORARILY
5. The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select the one correct answer. A. SC_OK B. SC_MOVED_TEMPORARILY C. SC_NOT_FOUND D. SC_INTERNAL_SERVER_ERROR E. ESC_BAD_REQUEST
A. A status of 200 to 299 signifies that the request was successful.
6. Which of the following statements are correct about the status of the Http response. Select the one correct answer. A. A status of 200 to 299 signifies that the request was successful. B. A status of 300 to 399 are informational messages. C. A status of 400 to 499 indicates an error in the server. D. A status of 500 to 599 indicates an error in the client.
B. getOutputStream
7. To send binary output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. A. getStream B. getOutputStream C. getBinaryStream D. getWriter
D. getWriter
8. To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. A. getStream B. getOutputStream C. getBinaryStream D. getWriter
a. True
9. Is the following statement true or false. URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL. a. True b. False
a) getObject d) getInt e) getString
Choose three correct statements in JDBC Chọn ít nhất một câu trả lời a) getObject b) getLine c) getText d) getInt e) getString
b) Two-tier and three-tier
JDBC supports ______ and ______ models. Chọn một câu trả lời a) Three-tier and four-tier b) Two-tier and three-tier c) None of the other choices d) Single-tier and two-tier
B. PUT method
Name the http method used to send resources to the server. Select the one correct answer. A. FTP methodd B. PUT method C. WRITE method D. COPY method
c) Both 1 and 2 are true
Study the statements: 1)When a JDBC connection is created, it is in auto-commit mode 2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly Chọn một câu trả lời a) Only statement 2 is true b) Both 1 and 2 are not true c) Both 1 and 2 are true d) Only statement 1 is true
d) error-page
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Do not include the element in enclosing parenthesis a) error b) exception c) exception-page d) error-page
c) getWriter
To send text outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. a) getOutputStream b) getBinaryStream c) getWriter d) getStream
b) jdbc:odbc:datasoursename
URL referring to databases use the form: Chọn một câu trả lời a) protocol:subprotocol:datasoursename b) jdbc:odbc:datasoursename c) protocol:datasoursename d) jdbc:datasoursename
a) createStatement(int, int); d) createStatement();
Which are the correct statements of Connection object? (Choose two) a) createStatement(int, int); b) createStatement(int, String); c) createStatement(String, int); d) createStatement();
b) executeBatch() c) execute() d) executeUpdate()
Which are the correct statements of ResultSet object? (Choose three) a) executeQueries() b) executeBatch() c) execute() d) executeUpdate()
d) sun.jdbc.odbc.JdbcOdbcDriver
Which is correct JDBC-ODBC driver name? Chọn một câu trả lời a) jdbc.odbc.sun.JdbcOdbcDriver b) sun.driver.jdbc.odbc c) jdbc.odbc.sun.driver d) sun.jdbc.odbc.JdbcOdbcDriver
c) Load Driver -> Connection -> Statement -> ResultSet
Which is correct sequence for a JDBC execution? Chọn một câu trả lời a) Connection -> Load Driver -> Statement -> ResultSet b) Load Driver -> Statement -> ResultSet -> Connection c) Load Driver -> Connection -> Statement -> ResultSet d) Statement -> Connection -> ResultSet -> Load Driver
c) \doc-root\WEB-INF\web.xml
Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer a) \doc-root\dd.xml b) \doc-root\WEB-INF\dd.xml c) \doc-root\WEB-INF\web.xml d) \doc-root\web.xml e) \doc-root\WEB_INF\dd.xml
B. COMPARE method
Which of the following is not a valid HTTP/1.1 method. Select the one correct answer. A. CONNECT method B. COMPARE method C. OPTIONS method D. TRACE method
c) The order of elements in deployment descriptor is important. The elements must follow a specific order
Which of these is true about deployment descriptors. Select the one correct answer Chọn một câu trả lời a) The servlet-mapping element, if defined, must be included within the servlet element. b) The web-app element must include the servlet element c) The order of elements in deployment descriptor is important. The elements must follow a specific order d) The elements of deployment descriptor are case insensitive
a) JDBC
______ is a set of java API for executing SQL statements. a) JDBC b) JAVADB c) ODBC d) None of the other choices