Skip to main content

Upwork JDBC 2.1 Test Answers

JBDC (Java Database Connectivity)
1. Under which category does the following driver fall:

 WebLogic's Tengah "all Java Type-3 driver"
 Answers: • Net-Protocol All-Java Driver

 2. Which JDBC driver is considered best in terms of performance and efficiency?
 Answers: • Type-1 Driver

 3. Please select all the correct options. JDBC Driver Manager is:
 Answers: • Able to activate registered drivers

 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?
 Answers: • ps.clearParameters(); ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate();

 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?
 Answers: • con.setAutoCommit(false);

 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?
 Answers: • jdbc:webx:webdsn

 7. You have to handle an erroneous situation in a transaction. Which method comes handy in this case?
 Answers: • con.rollback();

 8. How will you create a new instance of a JDBC driver explicitly?
 Answers: • Class.forName("driver").newInstance();

 9. JDBC is based on:
 Answers: • X/Open CLI (Call Level Interface)

 10. You are developing a shopping cart for your client. Where would you like to put your business logic?
 Answers: • In middleware servlets

 11. You want to execute the following query string, using the connection named "con":

 String query = "SELECT * FROM CUSTOMER";

 What should the syntax be?
 Answers: • Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(query);

 12. Which exception will be thrown in your code, if the specified driver could not be loaded?
 Answers: • ClassNotFoundException

 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:
 Answers: • Transaction

 14. Which of the following JDBC methods is used for retrieving large text strings?
 Answers: • getAsciiStream

 15. Open Database Connectivity is:
 Answers: • Platform independent

 16. Which of the following methods eliminates the need to call wasNull() method to handle null database fields?
 Answers: • getObject();

 17. Transactions have a property called atomicity, which means:
 Answers: • Everything takes place once

 18. What should the syntax be to establish a connection with a Database?
 Answers: • Connection con = DriverManager.getConnection(url,"myLogin", "myPassword");

 19. ResultSet objects follow index patterns of:
 Answers: • Array 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?
 Answers: • execute()

 21. You want to execute a CallableStatement named 'cs'. It is expected to return multiples results. Which of the following methods will you choose?
 Answers: • ResultSet rs=cs.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?
 Answers: • Reuse the database connection and use PreparedStatement objects with synchronized blocks

 23. Which of the following methods will you use to execute INSERT, UPDATE and DELETE SQL statements?
 Answers: • executeUpdate();

 24. How do you register a JDBC driver?
 Answers: • Class.forName("driver");

 25. Which of the following JDBC methods is used for retrieving large binary objects?
 Answers: • getBinaryStream

 26. Name the interface you will use to retrieve the underlying structure of the query result:
 Answers: • ResultSetMetaData

 27. Which type of statement object will you use to execute a stored procedure?
 Answers: • CallableStatement

 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:
 Answers: • getWarnings()

 29. 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?
 Answers: • while(rs.next())

 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:

 scrollrs.next();
 scrollrs.absolute(-10);
 scrollrs.relative(-6);

 At which row number is the cursor currently located?
 Answers: • 24

 31. 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?
 Answers: • Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet srs=st.executeQuery(qry);

 32. Which of the following is the syntax for creating a CallableStatement?
 Answers: • CallableStatement cs=con.prepareCall("{call SHOW_ORDER}")

 33. Which of the following is not true?
 Answers: • CallableStatement cannot take INOUT parameters

 34. Which of the following is not true for a ResultSet?
 Answers: • Methods next() and previous() return -1 beyond the ResultSet

 35. Java Database Connectivity (JDBC) is a:
 Answers: • Database-independent API

 36. Servlet developers should avoid using JDBC-ODBC bridge driver because:
 Answers: • The driver is of Type-1

 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?
 Answers: • srs.getRow()

 38. A user leaves an online shopping cart without checking out. Which of following interfaces will notify to Rollback the transaction?
 Answers: • HttpSessionBindingListener

 39. After executing the following code, resultvar contains false. What should the next step be?

 boolean resultvar=stmt.execute(sql);
 Answers: • stmt.getUpdateCount();

 40. SQLException has a method, which provides the feature of chaining or encapsulation of additional Exception objects. Identify the method from the following:
 Answers: • getNextException()

 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?
 Answers: • By session tracking and using HttpSession to hold a connection for each user

 42. SQLWarning object deals with database access warnings. It is a subclass of:
 Answers: • SQLException

 43. Will the below script execute properly?

 1.CREATE TABLE CUSTOMER 
 2.(
 3.CUS_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, SALES INTEGER
 4.)
 Answers: • Yes. The table will be created successfully.

 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?
 Answers: • SQLException

Comments

Popular posts from this blog

How to Choose Best Digital Marketing Engineer for your Business ?

Digital Marketing is new marketing concept of products, services and others using digital technologies on the internet. Previously we know digital marketing interms of internet marketing or online marketing. Digital marketing campaign is run on all the platform like; Desktop, tablet, mobile etc. Digital Marketing functions are SEO(search engine optimization), SEM(search engine marketing), Content Marketing, campaign marketing, e-commerce marketing, SMM(social media marketing), SMO(social media optimization), E-mail marketing, display advertising, games, ASO(Apps store optimization), Bulk SMS, branding, reputation management and other digital marketing platform techniques. If we can talk about simple SEO executive role, PPC Analyst role, SMO expert role or other single task handler then its a single activity performer. But if we hire a digital marketing engineer then its necessary that he has knowledge and working ability of all above digital marketing techniques. Simply we

Top SEO Companies in India by TOPSEO's Ranking

I am providing you the list of top 10 SEO Companies/Firms/Agencies in India by TOPSEO's  (January 2016) 1. SEO.IN  Year Founded: 2002 Website: http://www.seo.in / 2. SEOValley Solutions Private Limited Year Founded: 2000 Website: http://www.seovalley.com / 3. PageTraffic Year Founded: 2002 Website: http://www.pagetraffic.com/ 4. SeoTonic Web Solutions Private Ltd. Year Founded: 2006 Website: http://www.seotonic.com/ 5. Outsource SEO Year Founded: 2004 Website: http://www.outsourceseo.com/ 6. Ranking By SEO Year Founded: 2008 Website: http://www.rankingbyseo.com/ 7. Techmagnate Year Founded: 2006 Website: http://www.techmagnate.com / 8. SEO Discovery Year Founded: 2006 Website: http://www.seodiscovery.com/ 9. Greenlemon Year Founded: 1999 Website: http://greenlemon.in/ 10. SEOXperts India Year Founded: 2008 Website: http://www.seoxpertsindia.com/

Vivo IPL(10) 2017 Schedule , Player List , Team And Venue Details

IPL (10) 2017 Schedule is yet to be announced by the governing council of the Indian premier League . As per the previous sessions of the IPL it might also schedule to start from April 2017 to May 2017 . This session of IPL will also known as the Vivo Ipl (10)2017 because Vivo Electronics got the title sponsorship to 2 year after Pepsi terminated the contract back in 2016 . Like last year former IPL champions Chennai Super Kings and Rajasthan Royal will not participate the the tournament till this year . As per the schedule set by the IPL Committee, the Indian Premier League 2017 would be starting from 3rd of April and continue till 26th of May 2017. The first match of IPL 10 will have the IPL 5 winner Kolkata Knight Riders battling against Delhi Daredevils. The inaugural match as well as the final match of the IPL season 10 championship scheduled for 26th of May would be hosted by Eden Gardens, the home ground for superstar Shah Rukh Khan owned Kolkata Knight Riders. There wou