MIST 4630 Final Quizzes

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A __________ is a stand-alone, software component that enables a Java application to interact with a database. A) database driver B) DB ECU C) JDBC D) MySql connector

A

Flashback Question - A request object is created as soon as the request is received to hold all the data from the HTTPRequest and to provide access to that data. A) True B) False

A

Flashback Question - A response object is created as soon as the request is received to hold all the data and formatting to be sent with the HTTPResponse. A) True B) False

A

JDBC stands for __________________. A) Java Database Connectivity B) Java Database Code C) Java Data Browser Code D) Java Data Backup Connector

A

Multiple cookies can be carried at one time by a request. A) True B) False

A

The request and response objects are available to the doGet() and doPost() methods because they are passed as parameters for these methods by the Web server. A) True B) False

A

We can set the initial state of a servlet using initialization parameters. A) True B) False

A

What is the return value from: preparedStatement.executeUpdate("insert into T values (100, 'Smith')") ? A) an int value indicating how many rows are effected from the invocation B) a value indicating whether the SQL statement has been executed successfully C) void D) an object that contains the status of the execution

A

Which of the following servlet methods is the best place to include code that will retrieve servlet initialization parameters? A) init() B) doInit() C) doGet() D) doPost()

A

Which of the following state management techniques is useful for keeping data persistent as long as a user keeps a session open to our application? A) storing data as session attributes B) storing data as request attributes C) storing data as a cookie D) storing data in a database

A

Which of the following state management techniques is useful for passing data between components only during one request/response event? A) storing data as request attributes B) storing data as session attributes C) storing data as a cookie D) storing data in a database

A

Which of the following statements can be used to create a cookie that will be sent to the client? A) Cookie nameCookie = new Cookie("nameCookie", studentName); response.addCookie(nameCookie); B) Cookie nameCookie = response.addCookie(nameCookie); C) response.addCookie("nameCookie", studentName);

A

Which of the following statements will retrieve a servlet initialization paramater and store it as a serlvet instance variable? A) this.title = config.getInitParameter("Title"); B) this.title = servlet.getInitParameter("Title"); C) this.title = request.getInitParameter("Title"); D) this.title = config.getParameter("Title");

A

Which of the following statements will store an object called student temporarily so that it can be passed to and used by a view component? The object will no longer be available once the response is sent by the server. A) request.setAttribute("student", student); B) cookie.setAttribute("student", student);. C) response.getAttribute("student"); D) session.setAttribute("student", student);

A

With the MVC design pattern, it is possible to include multiple JSPs to provide different view options. A) True B) False

A

Assume that a database contains several records for the last name of Smith. Analyze the following code: PreparedStatement ps = connection.prepareStatement("select firstName, mi, lastName from Student where lastName = ?"; ps.setString(1, "Smith"); ResultSet resultSet = ps.executeQuery(); resultSet.next(); System.out.println(resultSet.getString(1)); A) resultSet.getString(1) returns the mi field in the result set. B) resultSet.getString(1) returns the firstName field in the result set. C) If the SQL SELECT statement returns no result, resultSet is null. D) The program will have a runtime error, because the cursor in resultSet does not point to a row. You must use resultSet.next() to move the cursor to the first row in the result set. Subsequently, resultSet.next() moves the cursor to the next row in the result set.

B

Assume that we have an html form with the following characteristics: -it includes a textbox named "temperature" -the form action specifies the URL mapping to a component called TemperatureServlet -the form method is set to GET Which of the following Java statements will forward execution of the application on to the view component conversion.jsp? A) RequestDispatcher dispatcher = request.getRequestDispatcher("conversion.jsp"); dispatcher.forward(); B) RequestDispatcher dispatcher = request.getRequestDispatcher("conversion.jsp"); dispatcher.forward(request, response); C) RequestDispatcher dispatcher = request.forward("conversion.jsp"); D) dispatcher.forward("conversion.jsp");

B

Flashback Question - The request and response objects are created when the HTTPRequest is received and last as long as the client maintains a session. A) True B) False

B

The request and response objects need to be declared before we can use them within our JSP code. A) True B) False

B

To store a cookie on the client, add it to the request object and, to retrieve a cookie from the client, you retrieve it off of the response object. A) True B) False

B

Which of the following state management techniques is useful for storing small amounts of data on the client side so that it can be retreived by the server during a later session? A) storing data in a database B) storing data as a cookie C) storing data as request attributes D) storing data as session attributes

B

Which of the following statements will allow us to access a session attribute and store it as a local variable? A) Student student = (Student) request.getAttribute("student"); B) Student student = (Student) session.getAttribute("student"); C) Student student = request.getAttribute("student"); D) Student student = session.getAttribute("student");

B

Assume that we have an html form with the following characteristics: -it includes a textbox named "temperature" -the form action specifies the URL mapping to a component called TemperatureServlet -the form method is set to GET Which of the following Java statements will declare and instantiate an instance of the TemperatureConverter class within the servlet? You may assume that the appropriate fields, constructors and methods are defined in the TemperatureConverter class. A) New TemperatureConverter tc; B) TemperatureConverter tc = request.getParameter("temperature"); C) TemperatureConverter tc = new TemperatureConverter(); D) None, there is no need to declare a model component in a servlet in order to use it.

C

Assume that we have an html form with the following characteristics: -it includes a textbox named "temperature" -the form action specifies the URL mapping to a component called TemperatureServlet -the form method is set to GET Which of the following Java statements should be used to retrieve the temperature values in the servlet and convert it to an int? A) int temperature = Integer.parseInt(request.getParameter("temp")); B) int temperature = request.getParameter("temperature"); C) int temperature = Integer.parseInt(request.getParameter("temperature")); D) int temperature = Double.parseDouble(request.getParameter("temperature"));

C

Assume that you have a servlet called PayrollServlet, which of the following statements will ensure that this servlet will run when the URL doPayroll is requested? A) @WebServlet("/PayrollServlet") B) doGet("doPayroll) C) @WebServlet("/doPayroll") D) @WebServlet("PayrollServlet=/doPayroll")

C

Assume that you have the following statement: PreparedStatement ps = connection.prepareStatement("select firstName, mi, lastName from Student where firstName = ? and lastName = ?"; To set a value John to the first parameter, use _________. A) ps.setString(0, "John"); B) preparedStatement.setString(1, "John""); C) ps.setString(1, "John"); D) preparedStatement.setString(0, "John");

C

Assume that you move the cursor of a ResultSet rs forward one record, but there are no more records there. What would be the result? A) the rs.next() method would return a value of true B) the rs.next() method would return a null value C) the rs.next() method would return a value of false D) a NoRecordFound exception

C

If a prepared statement preparedStatement is a SQL Insert statement, you execute the statement using _________. A) preparedStatement.query(); B) preparedStatement.executeQuery(); C) preparedStatement.executeUpdate(); D) preparedStatement.execute();

C

Which of the following Eclipse Dynamic Web Project folders is the best place to import the Connector/J jar file? A) src B) WebContent/Web-Inf C) WebContent/Web-Inf/lib D) WebContent

C

Which of the following methods will move the cursor for the ResultSet rs one record forward? A) rs.close() B) rs. getRow() C) rs.next() D) rs.last()

C

Which of the following statements can be used to connect to a local MySQL database named test? A) Connection connection = Request.getConnection("mysql:jdbc://localhost/test"); B) Connection connection = DriverManager.getConnection(jdbc:mysql://localhost/test); C) Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test"); D) Connection connection = DriverManager.connect("jdbc:mysql://localhost/test");

C

With the MVC design pattern, which of the following server side separation of concerns will be generally implemented using JSPs? A) Handle client-side behavior. B) Receive a request and control which components act on the request. C) Create the appropriate response to send to the client. D) Modeling our business components

C

With the MVC design pattern, which of the following server side separation of concerns will be generally implemented using Java Servlets? A) Create the appropriate response to send to the client. B) Handle client-side behavior. C) Receive a request and control which components act on the request. D) Modeling our business components

C

With the MVC design pattern, which of the following server side separation of concerns will be generally implemented using plain old java objects (POJOs)? A) Create the appropriate response to send to the client. B) Receive a request and control which components act on the request. C) Modeling our business components D) Handle client-side behavior.

C

A database URL for a MySQL database named test on host panda.armstrong.edu is ________. A) jdbc.mysql.//panda.armstrong.edu/test B) jdbc:mysql:/panda.armstrong.edu/test C) jdbc.mysql:///panda.armstrong.edu/test D) jdbc:mysql://panda.armstrong.edu/test

D

Assume that we have an html form with the following characteristics: it includes a textbox named "temperature" the form action specifies the URL mapping to a component called TemperatureServlet the form method is set to GET Which of the following is a true statement regarding this request? A) With the MVC design pattern, the TemperatureServlet will create the view component. B) The doPost() method of the servlet will be executed to honor the request. C) The values of the input element will be sent but no visible indication will be included in the URL. D) The values of the input element will be visibly concatenated to the URL when the submit button of the form is clicked.

D

Given the following code: PreparedStatement ps = connection.prepareStatement("select firstName, mi, lastName from Student where lastName = ?"; ps.setString(1, "Smith"); ResultSet resultSet = ps.executeQuery(); System.out.println(resultSet.getString(1)); What would be the result? A) resultSet.getString(1) returns the mi field in the result set. B) resultSet.getString(1) returns the firstName field in the result set. C) If the SQL SELECT statement returns no result, resultSet is null. D) The program will have a runtime error, because the cursor in resultSet does not point to a row. You must use resultSet.next() to move the cursor to the first row in the result set. Subsequently, resultSet.next() moves the cursor to the next row in the result set.

D

If a prepared statement preparedStatement is a SQL SELECT statement, you execute the statement using _________. A) preparedStatement.query(); B) preparedStatement.execute(); C) preparedStatement.executeUpdate(); D) preparedStatement.executeQuery();

D

In a relational data model, ________ provides the means for accessing and manipulating data. A) Structure B) Language C) Integrity D) SQL

D

Which of the following state management techniques is best for storing large amounts of data that will persist for a relatively long timeframe? A) storing data as request attributes B) storing data as a cookie C) storing data as session attributes D) storing data in a database

D

Which of the following statements can be used to store a value that will persist from the time it is stored until a user is no longer actively visiting a site? A) HttpSession session = session.setAttribute("student", student); B) HttpSession request = request.getRequest(); request.setAttribute("student", student); C) request.setAttribute("student", student); D) HttpSession session = request.getSession(); session.setAttribute("student", student);

D

Which of the following statements will retrieve an object called student that has been stored temporarily (until the response is sent) so that it can be used to create the view? A) Student student = request.getAttribute("student"); B) request.setAttribute("student", student); C) request.setAttribute("student", student); D) Student student = (Student) request.getAttribute("student");

D


Set pelajaran terkait

Ch. 10-12 Urinary System, Spleen, Retroperitoneum

View Set

2.1: Deterministic Finite Automata

View Set

Saunders Mental Health Questions

View Set

Geology Chapter 14: Energy Resources - Fossil Fuels

View Set

Intermediate Micro Econ Test 3 Study Guide

View Set