Placement Papers - Jamcracker

Jamcracker Software Technologies Interview Experience - Bangalore, May 10, 2016
Posted by :
Prem kumar
(0)
JDBC:
1. What is JDBC? What is the design pattern followed by JDBC?
ANS: JDBC is an interface that can be used by Java applications to access databases. Pattern-bridge design pattern.
2. What are the advantages and disadvantages of JDBC?
ANS: The significances are given below:
1) JDBC is the acronym stands for Java Database Connectivity.
2) Java Database Connectivity (JDBC) is a standard Java API.
3) It's purpose is to interact with the relational databases in Java.
4) JDBC is having a set of classes & interfaces which can be used from any Java application.
Disadvantage: Needs seperate driver for each database.
3. What are JDBC driver types? (Mention Name) Which type of JDBC driver is the fastest one?
ANS: 1) JDBC-ODBC Bridge plus ODBC driver, also called Type 1.
2) Native-API, partly Java driver, also called Type 2.
3) JDBC-Net, pure Java driver, also called Type 3.
4) Native protocol, pure Java driver, also called Type 4. And fastest Type 4 driver.
4. Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
ANS: No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.
5. A) ODBC stand for? B) OCL stands for?
ANS: ODBC-open database connectivity OCL-oracle callable interface.
6. What are the differences between JDBC and ODBC?
ANS: ODBC is an open interface which can be used by any application to communicate with any database system, while JDBC is an interface that can be used by Java applications to access databases.
7. What are the main components of JDBC?
ANS: Driver Manager, Driver, Connection, Statement, ResultSet.
8. What are the basic steps to create a JDBC application?
ANS: Following are the basic steps to create a JDBC application:
1. Class. ForName ("_");
2. Connection con = DriverManager. GetConnection ("_");
3. Statement st = con. CreateStatement ();
4. 1) executeQueary (); 2) executeUpdate (); 3) execute ();
5. St. Close (); Con. Close ();
9. Is it possible to register the driver more than one time for whole execution? (Y/N).
ANS: NO.
10. While installing JDK by default we are getting type3 driver? (Y/N).
ANS: NO.
11. Which driver is called Net-protocol?
ANS: Type3-driver.
12. Is it possible to change the JDBC protocol driver to driver? (Y/N).
ANS: Yes.
13. How to register a driver? (code).
ANS: Class. ForName ("----);
14. Class. ForName () throws which type of Exception?
ANS: ClassNotFoundException.
15. What causes "No suitable driver" error?
ANS: "No suitable driver" occurs during a call to the DriverManager. The getConnection method may be of any of the following reason:
-Due to failing to load the appropriate JDBC drivers before calling the getConnection method.
-It can be specifying an invalid JDBC URL, one that is not recognized by JDBC driver.
-This error can occur if one or more the shared libraries needed by the bridge cannot be loaded.
16. What is a Connection?
ANS: Connection interface consists of methods for contacting a database. The connection object represents communication context.
17. How to get the Connection object? (code).
ANS: Connection con = DriverManager. GetConnection ();
18. What are the different types of JDBC Statements?
ANS: Statement, PreparedStatement, CallableStatement.
19. How to get the Statement object? (code).
ANS: Statement statement = con. CreateStatement ();
20. Write down the return type of these methods. A. ExecuteUpdate () b. Execute () c. ExecuteQuery ().
ANS: a. Int b. Boolean c. ResultSet.
21. How to close the Statement object? (code).
ANS: statement. Close () ; (within try/catch block).
22. Write down the URL for Type1 Driver.
ANS: sun. Jdbc. Odbc. Driver. JdbcOdbcDriver.
23. Explain Type-4 Driver? What is the disadvantage?
ANS: It is a pure Java driver. It is lightweight and easy to install. JDBC has a set of classes & interfaces which can be used from any Java application.
Disadvantage: Needs separate driver for each database.
24. To use Type 4 Driver in Java program which jar file we need to copy into lib folder?
ANS: ojdbc14. Jar/ojdbc5. Jar.
25. Write down the URL for Type4 Driver.
ANS: jdbc:oracle:thin:@localhost:1521:XE.
26. What is a ResultSet? Write down the methods of ResultSet.
ANS: These objects hold data retrieved from a database after you execute an SQL query using Statement objects. It acts as an iterator to allow you to move through its data. The java. Sql. ResultSet interface represents the result set of a database query. Methods: next (), hasMoreElements ().
27. Write down the code for how to get ResultSet object.
ANS: Statement statement = conn. CreateStatement ();
ResultSet rs = statement. ExecuteQuery ();
28. Which interface we are using to get the meta information of the database?
ANS: DatabaseMetaData.
29. Which method is used to retrieve name of the particular column?
ANS: getColumnName ().
30. What is Metadata and why should you use it?
ANS: JDBC API has two Metadata interfaces: 1) DatabaseMetaData 2) ResultSetMetaData. The metadata provides comprehensive information about the database as a whole.
31. How can you retrieve data from the ResultSet? (code).
ANS: ResultSet rs = statement. ExecuteQuery ();
32. Write 4 methods from Statement object.
ANS: execute (), executeUpdate (), executeQuery (), close ().
33. What is the limitation of PreparedStatement?
ANS: PreparedStatement doesn't allow multiple values for one placeholder (?).
34. What are the utilities of the Callable statements?
ANS: Callable statements are mainly used in the JDBC applications. Callable statements are used to invoke stored procedures. This is mainly used in functions.
35. PreparedStatement is static object or dynamic object? (y/n).
ANS: static.
36. How to get the PreparedStatement object? (code).
ANS: String SQL = "any sql query";
PreparedStatement pstmt = conn. PrepareStatement (SQL);
37. Which method is used to call the StoredProcedure?
ANS: PrepareCall ("----").
38. Which argument is the default argument in case of StoredProcedure?
ANS: IN.
39. Write down the code to create a simple Stored Procedure.
ANS: Create or replace Procedure-name (Input parameters, Output Parameters (If required) ).
40. JDBC API is mainly divided into how many packages?
ANS: 2.
41. How many ways, we can create Stored Procedure? (mention the way).
ANS: 2 Ways.
42. Difference between Statement and Prepared Statement?
ANS: Prepared statements offer better performance, as they are pre-compiled. Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time. Prepared statements use bind arguments, which are sent to the database engine. This allows mapping different requests with the same prepared statement but different arguments to execute the same execution plan. Prepared statements are more secure because they use bind variables, which can prevent SQL injection attacks.
43. Result Set MetaData is an interface or class? (y/n).
ANS: Interface.
44. Write down the 3 methods of Result Set MetaData.
ANS: getColumnCount (), getColumnName (), getColumnSize ().
45. Write down the 3 methods of Database MetaData.
ANS: getDatabaseProductName () , getDriverName () , getDriverVersion (), getDatabaseProductVersion ().
46. What is the return type of next () method?
ANS: Boolean.
47. Which method is used to count the column?
ANS: getColumnCount ().
48. Write down the arguments of Stored Procedure.
ANS: IN, OUT, IN OUT.
49. DSN process vary from one database to another database? (Y/N).
ANS: Yes.
50. 'java. Sql. ResultSet' is an interface? (T/F).
ANS: Yes.
51. JDBC API is mainly divided into how many packages?
ANS: 2.
52. Which driver refers to the pure Java driver that uses middlerware driver to connect to a database?
ANS: Type2 Driver.
53. Mention the name of the SQL2 datatype.
ANS: BLOB, CLOB.
54. What are the factors that the JDBC driver performance depends on?
ANS: The JDBC driver performance depends on:
- The driver code quality.
-The driver code size.
-The database server & its load capability.
-The network topology.
-The number of times the request is being translated to a different API.
55. What are the utilities of the callable statements?
ANS: Callable statements are mainly used in the JDBC applications. Callable statements are used to invoke stored procedures. This is mainly used in functions.
56. What are the types of ResultSet in JDBC2.0?
ANS: 3 types: 1) ResultSet. TYPE_FORWARD_ONLY, 2) ResultSet. TYPE_SCROLL_SENSITIVE. 3) ResultSet. TYPE_SCROLL_INSENSITIVE,
57. List out the features of JDBC2.0.
ANS: 1) Scrollable ResultSet.
2) Methods to update ResultSet or Database table.
3) Batch updates.
4) Supports data types such as BLOB, CLOB, Array and Ref.
58. How to create the Statement object in JDBC2.0? (code).
ANS: Statement statement = con. CreateStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE);
59. What are the common JDBC exceptions?
ANS: SQLException, ClassNotFoundException, BatchUpdateException.
60. Difference Between "(SQL query) pre compile and stored procedure?
ANS: The difference between these two statements are:
1) SQL Query will be compiled every time it is executed. Whereas Stored Procedures are compiled only once when they are executed for the first time.
2) Stored Procedure is more efficient and fast execution than SQL query.
61. How cursor works in scrollable result set, mention methods name.
ANS: beforeFirst (), afterLast (), first (), last (), absolute (int row), relative (int row), previous (), next (), getRow ().
62. Write down the 4 mehods name, while updating through ResultSet.
ANS: moveToCurrentRow (), moveToInsertRow (), deleteRow (), insertRow ().
63. What is the use of BLOB, CLOB datatypes in JDBC2.0?
ANS: BLOB (BinayLarge Object) and CLOB (CharacterLargeObject) are SQL2 datatypes, which are introduced in JDBC2.0 version.
1. What is JDBC? What is the design pattern followed by JDBC?
ANS: JDBC is an interface that can be used by Java applications to access databases. Pattern-bridge design pattern.
2. What are the advantages and disadvantages of JDBC?
ANS: The significances are given below:
1) JDBC is the acronym stands for Java Database Connectivity.
2) Java Database Connectivity (JDBC) is a standard Java API.
3) It's purpose is to interact with the relational databases in Java.
4) JDBC is having a set of classes & interfaces which can be used from any Java application.
Disadvantage: Needs seperate driver for each database.
3. What are JDBC driver types? (Mention Name) Which type of JDBC driver is the fastest one?
ANS: 1) JDBC-ODBC Bridge plus ODBC driver, also called Type 1.
2) Native-API, partly Java driver, also called Type 2.
3) JDBC-Net, pure Java driver, also called Type 3.
4) Native protocol, pure Java driver, also called Type 4. And fastest Type 4 driver.
4. Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
ANS: No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.
5. A) ODBC stand for? B) OCL stands for?
ANS: ODBC-open database connectivity OCL-oracle callable interface.
6. What are the differences between JDBC and ODBC?
ANS: ODBC is an open interface which can be used by any application to communicate with any database system, while JDBC is an interface that can be used by Java applications to access databases.
7. What are the main components of JDBC?
ANS: Driver Manager, Driver, Connection, Statement, ResultSet.
8. What are the basic steps to create a JDBC application?
ANS: Following are the basic steps to create a JDBC application:
1. Class. ForName ("_");
2. Connection con = DriverManager. GetConnection ("_");
3. Statement st = con. CreateStatement ();
4. 1) executeQueary (); 2) executeUpdate (); 3) execute ();
5. St. Close (); Con. Close ();
9. Is it possible to register the driver more than one time for whole execution? (Y/N).
ANS: NO.
10. While installing JDK by default we are getting type3 driver? (Y/N).
ANS: NO.
11. Which driver is called Net-protocol?
ANS: Type3-driver.
12. Is it possible to change the JDBC protocol driver to driver? (Y/N).
ANS: Yes.
13. How to register a driver? (code).
ANS: Class. ForName ("----);
14. Class. ForName () throws which type of Exception?
ANS: ClassNotFoundException.
15. What causes "No suitable driver" error?
ANS: "No suitable driver" occurs during a call to the DriverManager. The getConnection method may be of any of the following reason:
-Due to failing to load the appropriate JDBC drivers before calling the getConnection method.
-It can be specifying an invalid JDBC URL, one that is not recognized by JDBC driver.
-This error can occur if one or more the shared libraries needed by the bridge cannot be loaded.
16. What is a Connection?
ANS: Connection interface consists of methods for contacting a database. The connection object represents communication context.
17. How to get the Connection object? (code).
ANS: Connection con = DriverManager. GetConnection ();
18. What are the different types of JDBC Statements?
ANS: Statement, PreparedStatement, CallableStatement.
19. How to get the Statement object? (code).
ANS: Statement statement = con. CreateStatement ();
20. Write down the return type of these methods. A. ExecuteUpdate () b. Execute () c. ExecuteQuery ().
ANS: a. Int b. Boolean c. ResultSet.
21. How to close the Statement object? (code).
ANS: statement. Close () ; (within try/catch block).
22. Write down the URL for Type1 Driver.
ANS: sun. Jdbc. Odbc. Driver. JdbcOdbcDriver.
23. Explain Type-4 Driver? What is the disadvantage?
ANS: It is a pure Java driver. It is lightweight and easy to install. JDBC has a set of classes & interfaces which can be used from any Java application.
Disadvantage: Needs separate driver for each database.
24. To use Type 4 Driver in Java program which jar file we need to copy into lib folder?
ANS: ojdbc14. Jar/ojdbc5. Jar.
25. Write down the URL for Type4 Driver.
ANS: jdbc:oracle:thin:@localhost:1521:XE.
26. What is a ResultSet? Write down the methods of ResultSet.
ANS: These objects hold data retrieved from a database after you execute an SQL query using Statement objects. It acts as an iterator to allow you to move through its data. The java. Sql. ResultSet interface represents the result set of a database query. Methods: next (), hasMoreElements ().
27. Write down the code for how to get ResultSet object.
ANS: Statement statement = conn. CreateStatement ();
ResultSet rs = statement. ExecuteQuery ();
28. Which interface we are using to get the meta information of the database?
ANS: DatabaseMetaData.
29. Which method is used to retrieve name of the particular column?
ANS: getColumnName ().
30. What is Metadata and why should you use it?
ANS: JDBC API has two Metadata interfaces: 1) DatabaseMetaData 2) ResultSetMetaData. The metadata provides comprehensive information about the database as a whole.
31. How can you retrieve data from the ResultSet? (code).
ANS: ResultSet rs = statement. ExecuteQuery ();
32. Write 4 methods from Statement object.
ANS: execute (), executeUpdate (), executeQuery (), close ().
33. What is the limitation of PreparedStatement?
ANS: PreparedStatement doesn't allow multiple values for one placeholder (?).
34. What are the utilities of the Callable statements?
ANS: Callable statements are mainly used in the JDBC applications. Callable statements are used to invoke stored procedures. This is mainly used in functions.
35. PreparedStatement is static object or dynamic object? (y/n).
ANS: static.
36. How to get the PreparedStatement object? (code).
ANS: String SQL = "any sql query";
PreparedStatement pstmt = conn. PrepareStatement (SQL);
37. Which method is used to call the StoredProcedure?
ANS: PrepareCall ("----").
38. Which argument is the default argument in case of StoredProcedure?
ANS: IN.
39. Write down the code to create a simple Stored Procedure.
ANS: Create or replace Procedure-name (Input parameters, Output Parameters (If required) ).
40. JDBC API is mainly divided into how many packages?
ANS: 2.
41. How many ways, we can create Stored Procedure? (mention the way).
ANS: 2 Ways.
42. Difference between Statement and Prepared Statement?
ANS: Prepared statements offer better performance, as they are pre-compiled. Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time. Prepared statements use bind arguments, which are sent to the database engine. This allows mapping different requests with the same prepared statement but different arguments to execute the same execution plan. Prepared statements are more secure because they use bind variables, which can prevent SQL injection attacks.
43. Result Set MetaData is an interface or class? (y/n).
ANS: Interface.
44. Write down the 3 methods of Result Set MetaData.
ANS: getColumnCount (), getColumnName (), getColumnSize ().
45. Write down the 3 methods of Database MetaData.
ANS: getDatabaseProductName () , getDriverName () , getDriverVersion (), getDatabaseProductVersion ().
46. What is the return type of next () method?
ANS: Boolean.
47. Which method is used to count the column?
ANS: getColumnCount ().
48. Write down the arguments of Stored Procedure.
ANS: IN, OUT, IN OUT.
49. DSN process vary from one database to another database? (Y/N).
ANS: Yes.
50. 'java. Sql. ResultSet' is an interface? (T/F).
ANS: Yes.
51. JDBC API is mainly divided into how many packages?
ANS: 2.
52. Which driver refers to the pure Java driver that uses middlerware driver to connect to a database?
ANS: Type2 Driver.
53. Mention the name of the SQL2 datatype.
ANS: BLOB, CLOB.
54. What are the factors that the JDBC driver performance depends on?
ANS: The JDBC driver performance depends on:
- The driver code quality.
-The driver code size.
-The database server & its load capability.
-The network topology.
-The number of times the request is being translated to a different API.
55. What are the utilities of the callable statements?
ANS: Callable statements are mainly used in the JDBC applications. Callable statements are used to invoke stored procedures. This is mainly used in functions.
56. What are the types of ResultSet in JDBC2.0?
ANS: 3 types: 1) ResultSet. TYPE_FORWARD_ONLY, 2) ResultSet. TYPE_SCROLL_SENSITIVE. 3) ResultSet. TYPE_SCROLL_INSENSITIVE,
57. List out the features of JDBC2.0.
ANS: 1) Scrollable ResultSet.
2) Methods to update ResultSet or Database table.
3) Batch updates.
4) Supports data types such as BLOB, CLOB, Array and Ref.
58. How to create the Statement object in JDBC2.0? (code).
ANS: Statement statement = con. CreateStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE);
59. What are the common JDBC exceptions?
ANS: SQLException, ClassNotFoundException, BatchUpdateException.
60. Difference Between "(SQL query) pre compile and stored procedure?
ANS: The difference between these two statements are:
1) SQL Query will be compiled every time it is executed. Whereas Stored Procedures are compiled only once when they are executed for the first time.
2) Stored Procedure is more efficient and fast execution than SQL query.
61. How cursor works in scrollable result set, mention methods name.
ANS: beforeFirst (), afterLast (), first (), last (), absolute (int row), relative (int row), previous (), next (), getRow ().
62. Write down the 4 mehods name, while updating through ResultSet.
ANS: moveToCurrentRow (), moveToInsertRow (), deleteRow (), insertRow ().
63. What is the use of BLOB, CLOB datatypes in JDBC2.0?
ANS: BLOB (BinayLarge Object) and CLOB (CharacterLargeObject) are SQL2 datatypes, which are introduced in JDBC2.0 version.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers