Saturday, January 2, 2016

JDBC 2.1 Test answers 2016.

JDBC 2.1 Test answers 2016.

Find Complete and recently updated Correct Question and answers of JDBC of Upwork. All Answers updated regularly with new questions. Upwork JDBC answers of 2016.



Question:* Under which category does the following driver fall: WebLogic's Tengah "all Java Type-3 driver"

Answer: • Net-Protocol All-Java Driver

Question:* Which JDBC driver is considered best in terms of performance and efficiency?

Answer: • Type-1 Driver

Question:* Please select all the correct options. JDBC Driver Manager is:

Answer: • Able to activate registered drivers

Question:* Consider the following statement: PreparedStatement ps=con.prepareStatement("INSERT INTO ORDER (CUSTOMER_ID ,PRICE) VALUES(?,?)"); Which of the following should come after this statement?

Answer: • ps.clearParameters(); ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate();

Question:* You want to start a transaction for bank account processing. Which of the following methods will you execute on the Connection object to begin it?

Answer: • con.setAutoCommit(false);

Question:* You need to use a third party driver for establishing a connection with the database. The subprotocol is "webx" and the DSN is "webdsn". What is the syntax of the URL?

Answer: • jdbc:webx:webdsn

Question:* You have to handle an erroneous situation in a transaction. Which method comes handy in this case?

Answer: • con.rollback();

Question:* How will you create a new instance of a JDBC driver explicitly?

Answer: • Class.forName("driver").newInstance();

Question:* JDBC is based on:

Answer: • X/Open CLI (Call Level Interface)

Question:* You are developing a shopping cart for your client. Where would you like to put your business logic?

Answer: • In middleware servlets

Question:* You want to execute the following query string, using the connection named "con": String query = "SELECT * FROM CUSTOMER"; What should the syntax be?

Answer: • Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(query);

Question:* Which exception will be thrown in your code, if the specified driver could not be loaded?

Answer: • ClassNotFoundException

Question:* A process allows you to group multiple SQL statements. Commit or Rollback can be performed on the group together. This process is known as:

Answer: • Transaction

Question:* Which of the following JDBC methods is used for retrieving large text strings?

Answer: • getAsciiStream

Question:* Open Database Connectivity is:

Answer: • Platform independent

Question:* Which of the following methods eliminates the need to call wasNull() method to handle null database fields?

Answer: • getObject();

Question:* Transactions have a property called atomicity, which means:

Answer: • Everything takes place once

Question:* What should the syntax be to establish a connection with a Database?

Answer: • Connection con = DriverManager.getConnection(url,"myLogin", "myPassword");

Question:* ResultSet objects follow index patterns of:

Answer: • Array standard

Question:* When you are handling user-submitted SQL, you may retrieve a ResultSet or a count. Which of the following methods is handy in this situation?

Answer: • execute()

Question:* You want to execute a CallableStatement named 'cs'. It is expected to return multiples results. Which of the following methods will you choose?

Answer: • ResultSet rs=cs.execute()

Question:* Your project leader has asked you to improve the performance of JDBC connectivity by reusing objects in your Servlet's code. Which of the following is an appropriate solution?

Answer: • Reuse the database connection and use PreparedStatement objects with synchronized blocks

Question:* Which of the following methods will you use to execute INSERT, UPDATE and DELETE SQL statements?

Answer: • executeUpdate();

Question:* How do you register a JDBC driver?

Answer: • Class.forName("driver");

Question:* Which of the following JDBC methods is used for retrieving large binary objects?

Answer: • getBinaryStream

Question:* Name the interface you will use to retrieve the underlying structure of the query result:

Answer: • ResultSetMetaData

Question:* Which type of statement object will you use to execute a stored procedure?

Answer: • CallableStatement

Question:* A warning can be thrown by a Connection object, a Statement object or a ResultSet object. Which method is used to retrieve the warning:

Answer: • getWarnings()

Question:* You have obtained a ResultSet object named 'rs' after executing the following query: SELECT * FROM CUSTOMER Which loop can you use to return all the records in the ResultSet?

Answer: • while(rs.next())

Question:* You executed a query to retrieve 40 products from the database and obtained a scrollable ResultSet named 'scrollrs'. You started scrolling the ResultSet as follows: scrollrs.next(); scrollrs.absolute(-10); scrollrs.relative(-6); At which row number is the cursor currently located?

Answer: • 24

Question:* The code segment below defines a query: String qry="SELECT CUS_NAME, PRICE FROM CUSTOMER"; Which of the following code snippets will create a scrollable ResultSet?

Answer: • Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet srs=st.executeQuery(qry);

Question:* Which of the following is the syntax for creating a CallableStatement?

Answer: • CallableStatement cs=con.prepareCall("{call SHOW_ORDER}")

Question:* Which of the following is not true?

Answer: • CallableStatement cannot take INOUT parameters

Question:* Which of the following is not true for a ResultSet?

Answer: • Methods next() and previous() return -1 beyond the ResultSet

Question:* Java Database Connectivity (JDBC) is a:

Answer: • Database-independent API

Question:* Servlet developers should avoid using JDBC-ODBC bridge driver because:

Answer: • The driver is of Type-1

Question:* You have obtained a scrollable ResultSet named 'srs' by executing a query. Which of the following methods will you use to verify the position of the cursor?

Answer: • srs.getRow()

Question:* A user leaves an online shopping cart without checking out. Which of following interfaces will notify to Rollback the transaction?

Answer: • HttpSessionBindingListener

Question:* After executing the following code, resultvar contains false. What should the next step be? boolean resultvar=stmt.execute(sql);

Answer: • stmt.getUpdateCount();

Question:* SQLException has a method, which provides the feature of chaining or encapsulation of additional Exception objects. Identify the method from the following:

Answer: • getNextException()

Question:* Your project leader has given you a new task. You have to work on a module in which the transaction has to be extended across multiple page requests and multiple servlets. How will you implement this?

Answer: • By session tracking and using HttpSession to hold a connection for each user

Question:* SQLWarning object deals with database access warnings. It is a subclass of:

Answer: • SQLException

Question:* Will the below script execute properly? 1.CREATE TABLE CUSTOMER 2.( 3.CUS_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, SALES INTEGER 4.)

Answer: • Yes. The table will be created successfully.

Question:* You are trying to connect to a database through JDBC. There is a problem with one of the methods immediately after the driver has been loaded. Which exception will be thrown?

Answer: • SQLException



HTML5 Upwork (oDesk) TEST ANSWERS 2022

HTML5 Upwork (oDesk) TEST ANSWERS 2022 Question: Which of the following is the best method to detect HTML5 Canvas support in web br...

Disqus for upwork test answers