0

Java Database Interfaces

Description: Concept Based Questions
Number of Questions: 15
Created by:
Tags: Concept Based Questions Java Basics Databases
Attempted 0/15 Correct 0 Score 0

Which of the following methods is present in the Result set interface in java database programming?

  1. moveToCurrentRow()

  2. moveToNextRow()

  3. moveToPreviousRow()

  4. moveToFirstRow()

  5. moveToLastRow()


Correct Option: A
Explanation:

This is the correct choice because moveToCurrentRow() method is present in ResultSet interface. This method moves the cursor to the remembered cursor position, usually the current row. So, this is the correct choice.

Which of the following methods in ResultSet interface returns true to check whether the current row has been updated in a table?

  1. rowUpdated()

  2. isUpdated()

  3. hasUpdated()

  4. Updated()

  5. isRowUpdated()


Correct Option: A
Explanation:

rowUpdated() method is present in the ResultSet interface and it retrieves whether the current row in the table has been updated or not. So, this is the correct choice.

Which of the following methods in ResultSet interface returns true to indicate whether the current row has had an insertion or not?

  1. isRowInserted()

  2. hasInserted()

  3. isInserted()

  4. rowInserted()

  5. Inserted()


Correct Option: D
Explanation:

rowInserted() method is present in the ResultSet interface and it retrieves whether the current row has had an insertion or not. So, this answer is correct.

Which of the following methods in ResultSetMetaData interface retrieves the designated column's database-specific type name?

  1. getColumnName(int column)

  2. getColumnType(int column)

  3. getColumnTypeName(int column)

  4. getColumnNameType(int column)

  5. getColTypeName(int column)


Correct Option: C
Explanation:

getColumnTypeName(int column) method is present in the ResultSetMetaData interface and it retrieves the designated column's database-specific type name. So, this answer is correct.

Which of the following methods is not defined in the SQLException class in java?

  1. getErrorCode()

  2. getNextException()

  3. getPreviousException()

  4. getSQLState()

  5. setNextException(SQLException ex)


Correct Option: C
Explanation:

There is no method named getPreviosException() in java database programing. So, this answer is true.

How many constructors of class SQLTimeoutException are there in java database programming?

  1. 10

  2. 9

  3. 8

  4. 7

  5. 6


Correct Option: C
Explanation:

There are 8 constructors of SQLTimeoutException class in java. These are: 1.) SQLTimeoutException(): Constructs a SQLTimeoutException object. 2.) SQLTimeoutException(String reason): Constructs a SQLTimeoutException object with a given reason. 3.) SQLTimeoutException(String reason, String SQLState): Constructs a SQLTimeoutException object with a given reason and SQLState. 4.) SQLTimeoutException(String reason, String SQLState, int vendorCode): Constructs a SQLTimeoutException object with a given reason, SQLState and vendorCode. 5.) SQLTimeoutException(String reason, String SQLState, int vendorCode, Throwable cause): Constructs a SQLTimeoutException object with a given reason, SQLState, vendorCode and cause. 6.) SQLTimeoutException(String reason, String SQLState, Throwable cause): Constructs a SQLTimeoutException object with a given reason, SQLState and cause. 7.) SQLTimeoutException(String reason, Throwable cause): Constructs a SQLTimeoutException object with a given reason and cause. 8.) SQLTimeoutException(Throwable cause): Constructs a SQLTimeoutException object with a given cause. So, this is the correct answer.

Which of the following methods is not present in the Connection interface in java database programming?

  1. abort(Executor executor)

  2. createStatement()

  3. getMetaData()

  4. getNetworkTimeout()

  5. createXMLSQL()


Correct Option: E
Explanation:

There is no method named createXMLSQL() in the Connection interface. The correct method name is createSQLXML(). This method constructs an object that implements the SQLXML interface. So, this answer is correct.

Which of the following methods is not defined in the DataTruncation class in java database programming?

  1. getTransferSize()

  2. getDataSize()

  3. getRead()

  4. getWrite()

  5. getIndex()


Correct Option: D
Explanation:

There is no method named getWrite() defined in the DataTruncation class in java. So, this answer is true.

Which of the following methods is not present in the Statement interface in java database programming?

  1. addBatch(String sql)

  2. closeOnCompletion()

  3. executeQuery(String sql)

  4. executeBatch()

  5. getResults()


Correct Option: E
Explanation:

There is no method named getResults() in the Statement interface. The correct method name is getMoreResults(), which moves to this Statement object's next result; returns true if it is a ResultSet object and implicitly closes any current ResultSet object(s) obtained with the method getResultSet. So, this answer is true.

Which of the following methods is present in the Connection interface in java database programming?

  1. isValid(int timeout)

  2. isReadable()

  3. isWritable()

  4. isInvalid(int timeout)

  5. isPrepared()


Correct Option: A
Explanation:

isValid(int timeout) method is present in the Connection interface and it returns true if the connection has not been closed and is still valid. So, this answer is correct.

Which of the following methods in ResultSet interface returns true to indicate whether a row has been deleted?

  1. isDeleted()

  2. Deleted()

  3. rowDeleted()

  4. hasDeleted()

  5. isRowDeleted()


Correct Option: C
Explanation:

This is the correct choice because rowDeleted() method is present in the ResultSet interface and it retrieves whether a row has been deleted or not. So, this is the correct answer.

How many methods are defined in the Time class in java?

  1. 10

  2. 9

  3. 8

  4. 7

  5. 6


Correct Option: A
Explanation:

There are 10 methods present in the Time class in java. These are: 1.) getDate() 2.) getDay() 3.) getMonth() 4.) getYear() 5.) setDate(int i) 6.) setMonth(int i) 7.) setTime(int i) 8.) setYear(int i) 9.) toString(): Formats a time in JDBC time escape format. 10.) valueOf(String s): Converts a string in JDBC time escape format to a time value. So, this is the correct answer.

Which of the following methods is present in the Statement interface in java database programming?

  1. isCloseOnInsertion()

  2. isCloseOnCompletion()

  3. isCloseOnDeletion()

  4. isCloseAfterUpdate()

  5. isCloseAfterInsertion()


Correct Option: B
Explanation:

isCloseOnCompletion() method is present in the Statement interface. This method returns a value indicating whether this Statement will be closed when all its dependent result sets are closed. So, this answer is true.

Which of the following methods is/are present in the Connection interface in java database programming?

  1. setSavepoint()

  2. setSavepoint(String name)

  3. getConnection()

  4. Both 1 and 2

  5. Both 2 and 3


Correct Option: D
Explanation:

Both 1 and 2 are present in the Connection interface. So, this answer is correct.

Which of the following methods is not present in the PreparedStatement interface in java database programming?

  1. addBatch()

  2. executeQuery()

  3. executeBatch()

  4. execute()

  5. getMetaData()


Correct Option: C
Explanation:

executeBatch() method is present in the Statement interface, not in the PreparedStatement interface and it submits a batch of commands to the database for execution and if all commands execute successfully, it returns an array of update counts. So, this answer is false.

- Hide questions