250+ TOP MCQs on Access SQL From a Programming Language

Database Multiple Choice Questions & Answers on “Access SQL From a Programming Language”.

1. Which of the following is used to access the database server at the time of executing the program and get the data from the server accordingly?
a) Embedded SQL
b) Dynamic SQL
c) SQL declarations
d) SQL data analysis

Answer: b
Clarification: Embedded SQL, the SQL statements are identified at compile time using a preprocessor. The preprocessor submits the SQL statements to the database system for precompilation and optimization; then it replaces the SQL statements in the application program with appropriate code and function calls before invoking the programming-language compiler.

2. Which of the following header must be included in java program to establish database connectivity using JDBC ?
a) Import java.sql.*;
b) Import java.sql.odbc.jdbc.*;
c) Import java.jdbc.*;
d) Import java.sql.jdbc.*;

Answer: a
Clarification: The Java program must import java.sql.*, which contains the interface definitions for the functionality provided by JDBC.

3. DriverManager.getConnection(_______ , ______ , ______)
What are the two parameters that are included?
a) URL or machine name where server runs, Password, User ID
b) URL or machine name where server runs, User ID, Password
c) User ID, Password, URL or machine name where server runs
d) Password, URL or machine name where server runs, User ID

Answer: b
Clarification: The database must be opened first in order to perform any operations for which this get connection method is used.

4. Which of the following invokes functions in sql?
a) Prepared Statements
b) Connection statement
c) Callable statements
d) All of the mentioned

Answer: c
Clarification: JDBC provides a Callable Statement interface that allows invocation of SQL stored procedures and functions.

5. Which of the following function is used to find the column count of the particular resultset?
a) getMetaData()
b) Metadata()
c) getColumn()
d) get Count()

Answer: a
Clarification: The interface ResultSet
has a method, getMetaData(), that returns a ResultSetMetaData object that contains metadata about the result set. ResultSetMetaData, in turn, has methods to find metadata information, such as the number of columns in the result, the name of a specified column, or the type of a specified column.

6. Which of the following is a following statement is a prepared statements?
a) Insert into department values(?,?,?)
b) Insert into department values(x,x,x)
c) SQLSetConnectOption(conn, SQL AUTOCOMMIT, 0)
d) SQLTransact(conn, SQL ROLLBACK)

Answer: a
Clarification:? is used as a placeholder whose value can be provided later.

7. Which of the following is used as the embedded SQL in COBOL?
a) EXEC SQL ;
b) EXEC SQL END-EXEC
c) EXEC SQL
d) EXEC SQL END EXEC;

Answer: b
Clarification: EXEC SQL ; is normally in C.

8. Which of the following is used to distinguish the variables in SQL from the host language variables?
a) .
b) –
c) :
d) ,

Answer: b
Clarification:

EXEC SQL
DECLARE c cursor FOR
SELECT ID, name
FROM student
WHERE tot cred > :credit amount;

.

9. The update statement can be executed in host language using
a) EXEC SQL update c;
b) EXEC SQL update c into :si, :sn;
c)

   EXEC SQL
   UPDATE instructor
   SET salary = salary + 100
   WHERE CURRENT OF c;

d) EXEC SQL update END-SQL

Answer: c
Clarification: The SQL can be terminated by ; to terminate the sentence.

10. Which of the following is used to access large objects from a database ?
a) setBlob()
b) getBlob()
c) getClob()
d) all of the mentioned

Answer: d

Leave a Reply

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