Upwork JDBC 2.1 Test Answers 2016

Till 28 April 2016, this Upwork JDBC 2.1 Test attended by 4,800 freelancers and total 2,350 freelancers qualified it. Please Try to review each questions and answers properly. Take your time. Maybe you can have Top Result in Upwork JDBC 2.1 Test.

Do you need prove? watch this video.

Upwork JDBC 2.1 Test 2016

44 Answered Test Questions:
1. Under which category does the following driver fall:

WebLogic’s Tengah “all Java Type-3 driver”
a. JDBC-ODBC Bridge Driver
a. Native-API Partly-Java Driver
a. Net-Protocol All-Java Driver
a. Native-Protocol All-Java Driver
a. Native-Protocol Part-Java Driver
2. Which JDBC driver is considered best in terms of performance and efficiency?
a. Type-1 Driver
a. Type-2 Driver
a. Type-3 Driver
a. Type-4 Driver
3. Please select all the correct options. JDBC Driver Manager is:
a. Able to activate registered drivers
a. Able to activate unregistered drivers
a. Not required for activation of drivers with DataSource
a. Required for activation of drivers with DataSource
4. Consider the following statement:

PreparedStatement ps=con.prepareStatement(“INSERT INTO ORDER (CUSTOMER_ID ,PRICE) VALUES(?,?)”);

Which of the following should come after this statement?
a. ps.clearParameters(); ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate(sql);
a. ps.clearParameters(); ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate();
a. ps.clear(); ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate(sql);
a. ps.clearParameters(); ps.setInt(1,3.09); ps.setDouble(2,790.50); ps.execute(sql);
a. ps.clearParameters(); ps.setDouble(2,790.50); ps.execute(sql);
5. 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?
a. con.setAutoCommit(false);
a. con.setCommit(false);
a. con.setAutoCommit();
a. con.setAutoCommit(true);
a. con.autoCommit();
6. 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?
a. jdbc:odbc:webx:webdsn
a. odbc:jdbc:webx:webdsn
a. jdbc:webx:webdsn
a. thin:jdbc:odbc:dsn:webdsn
a. thick:jdbc:odbc:dsn:webdsn
a. None of the above
7. You have to handle an erroneous situation in a transaction. Which method comes handy in this case?
a. con.commit(false);
a. con.commit();
a. con.rollback();
a. con.revertback();
a. con.rollback(true);
8. How will you create a new instance of a JDBC driver explicitly?
a. Class.forName(“driver”);
a. Class.newInstance(“driver”);
a. Class.driver(“driver”);
a. Class.getDriver(“driver”);
a. Class.forName(“driver”).newInstance();
9. JDBC is based on:
a. X/Open CLI (Call Level Interface)
a. JDBC/Open CLI
a. Java/Open CLI
a. X/Close CLI
10. You are developing a shopping cart for your client. Where would you like to put your business logic?
a. Inside the database
a. Inside the client application
a. In middleware servlets
a. In COM / DCOM components
a. Inside the code for the cart
11. You want to execute the following query string, using the connection named “con”:

String query = “SELECT * FROM CUSTOMER”;

What should the syntax be?
a. Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(query);
a. Statement stmt=new Statement(); ResultSet rs=stmt.executeQuery(query);
a. Statement stmt=con.createStatement(); ResultSet rs=stmt.execute(query);
a. Statement stmt=con.getStatement(); ResultSet rs=stmt.executeQuery(query);
a. Statement stmt=con.getStatement(); ResultSet rs=con.executeQuery(query);
12. Which exception will be thrown in your code, if the specified driver could not be loaded?
a. ActivationException
a. ClassNotFoundException
a. ClassNotAvailableException
a. ClassUnavailableException
a. InstantiationException
13. A process allows you to group multiple SQL statements. Commit or Rollback can be performed on the group together. This process is known as:
a. Binding
a. Synchronization
a. Registry
a. Transaction
a. Late binding
14. Which of the following JDBC methods is used for retrieving large text strings?
a. getBinaryStream
a. getText
a. getAsciiStream
a. getString
a. getObjectStream
15. Open Database Connectivity is:
a. Platform independent
a. Platform dependent
a. Architecture neutral
a. Network independent
a. Machine independent
16. Which of the following methods eliminates the need to call wasNull() method to handle null database fields?
a. getObject();
a. getInt();
a. getString();
a. getFloat();
a. getNull();
17. Transactions have a property called atomicity, which means:
a. Everything takes place one by one
a. Everything takes place once
a. Everything takes place randomly
a. Everything takes place twice
a. Everything takes place thrice
18. What should the syntax be to establish a connection with a Database?
a. Connection con = DriverManager.getConnection(url,”myLogin”, “myPassword”);
a. Connection con = DriverManager.getConnection(“myLogin”, “myPassword”,url);
a. Connection con = DriverManager.getConnection(“myLogin”, “myPassword”);
a. Connection con = DriverManager.setConnection(url,”myLogin”, “myPassword”);
a. Connection con = DriverManager.createConnection(url,”myLogin”, “myPassword”);
19. ResultSet objects follow index patterns of:
a. Array standard
a. Java standard
a. RDBMS standard
a. C++ standard
a. PL/SQL standard
20. 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?
a. executeQuery()
a. exceuteUpdate()
a. execute()
a. executeQueryUpdate()
a. update()
21. You want to execute a CallableStatement named ‘cs’. It is expected to return multiples results. Which of the following methods will you choose?
a. ResultSet rs=cs.execute()
a. ResultSet rs=cs.executeQuery()
a. ResultSet rs=cs.executeUpdate()
a. ResultSet rs=cs.executeQuery(sql)
a. ResultSet rs=execute()
22. 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?
a. Reuse the database connection and reuse PreparedStatement objects
a. Reuse the database connection and use PreparedStatement objects with synchronized blocks
a. Reuse the database connection only
a. Reuse the PreparedStatement objects only
a. Reuse the GetPreparedStatement objects only
23. Which of the following methods will you use to execute INSERT, UPDATE and DELETE SQL statements?
a. executeQuery();
a. executeUpdate();
a. executeQueryUpdate();
a. update();
a. query();
24. How do you register a JDBC driver?
a. Class.forName(“driver”);
a. Class.newInstance(“driver”);
a. Class.driver(“driver”);
a. Class.getDriver(“driver”);
a. Class.postDriver(“driver”);
25. Which of the following JDBC methods is used for retrieving large binary objects?
a. getBinaryStream
a. getText
a. getAsciiStream
a. getString
a. getObjectStream
26. Name the interface you will use to retrieve the underlying structure of the query result:
a. ResultSet
a. ResultSetMetaData
a. ResultStructure
a. Result
a. ResultMetaData
27. Which type of statement object will you use to execute a stored procedure?
a. Statement
a. PreparedStatement
a. CallableStatement
a. StoredStatement
a. Stat
28. A warning can be thrown by a Connection object, a Statement object or a ResultSet object. Which method is used to retrieve the warning:
a. getWarnings()
a. getWarned()
a. getWarning()
a. getError()
a. getErrorsWarning()
29. You have obtained a ResultSet object named ‘rs’ after executing the following query:


Which loop can you use to return all the records in the ResultSet?
a. while(rs.next())
a. while(rs.hasNext())
a. while(true)
a. while(rs.nextElement())
30. 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:


At which row number is the cursor currently located?
a. 16
a. 24
a. 26
a. 17
a. 6
31. The code segment below defines a query:


Which of the following code snippets will create a scrollable ResultSet?
a. Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet srs=st.executeQuery(qry);
a. Statement st=con.createStatement(qry,ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_SCROLL_SENSITIVE); ResultSet srs=st.executeQuery();
a. Statement st=con.createStatement(qry,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet srs=st.executeQuery();
a. Statement st=con.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.TYPE_SCROLL_SENSITIVE); ResultSet srs=st.executeQuery(qry);
32. Which of the following is the syntax for creating a CallableStatement?
a. CallableStatement cs=con.prepareCall(“{call SHOW_ORDER}”)
a. CallableStatement cs=con.prepareCall(‘{call SHOW_ORDER}’)
a. CallableStatement cs=con.prepareCall(“(call SHOW_ORDER)”)
a. CallableStatement cs=con.prepareCall(“call SHOW_ORDER”)
a. CallableStatement cs=prepareCall(“call SHOW_ORDER”)
33. Which of the following is not true?
a. CallableStatement is a subclass of PreparedStatement
a. CallableStatement can take PreparedStatement as an input parameter
a. CallableStatement can use executeUpdate() method
a. CallableStatement can use execute() method
a. CallableStatement cannot take INOUT parameters
34. Which of the following is not true for a ResultSet?
a. JDBC 2.0 API supports Scrollable ResultSets
a. ResultSet cursors are moved forward using next() method
a. ResultSet cursors are moved backwards using previous() method
a. Methods next() and previous() return -1 beyond the ResultSet
35. Java Database Connectivity (JDBC) is a:
a. Database-dependent API
a. Database-independent API
a. Machine-dependent API
a. Network-dependent database API
36. Servlet developers should avoid using JDBC-ODBC bridge driver because:
a. Drivers are bundled with JDK
a. The driver’s native code can crash the entire server
a. The driver is not secure
a. The driver is of Type-1
a. The driver is of Type-2
37. 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?
a. srs.relative(-4)
a. srs.relative()
a. srs.absolute(-4)
a. srs.getRow()
a. srs.postRow()
38. A user leaves an online shopping cart without checking out. Which of following interfaces will notify to Rollback the transaction?
a. HttpSession
a. HttpSessionBindingListener
a. HttpServlet
a. SingleThreadModel
a. FtpSession
39. After executing the following code, resultvar contains false. What should the next step be?

boolean resultvar=stmt.execute(sql);
a. stmt.getResultSet();
a. stmt.getUpdateCount();
a. stmt.executeUpdate();
a. stmt.executeQuery();
a. stmt.executeUpdateQuery();
40. SQLException has a method, which provides the feature of chaining or encapsulation of additional Exception objects. Identify the method from the following:
a. getEncapsulatedException()
a. getEncapException()
a. getMessage()
a. getNextException()
a. getException()
41. 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?
a. By synchronizing the doPost() method
a. By creating a new connection for each transaction
a. By session tracking and using HttpSession to hold a connection for each user
a. By creating a single connection in the init() method and implementing SingleThreadModel
a. By synchronizing doGet ()
42. SQLWarning object deals with database access warnings. It is a subclass of:
a. SQLWarn
a. SQLException
a. SQLError
a. SQLWarning
a. SQLErrorsWarning
43. Will the below script execute properly?

a. Yes. The table will be created successfully.
a. No. Line 3 should be modified to: VARCHAR(32) CUS_NAME,INTEGER SUP_ID ,FLOAT PRICE , INTEGER SALES
a. No. Line 3 should be modified to: ‘CUS_NAME VARCHAR(32)’,’SUP_ID INTEGER’,’ PRICE FLOAT’, ‘SALES INTEGER’
a. No. Line 3 should be modified to: ‘CUS_NAME’ VARCHAR(32),’SUP_ID’ INTEGER,’PRICE’ FLOAT, ‘SALES’ INTEGER
44. 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?
a. ClassNotFoundException
a. SQLException
a. SQLNotFoundException
a. ActivationException
a. JDBCException

Please follow and like to help us:

Leave a Reply

Your email address will not be published. Required fields are marked *