PL/SQL Test Questions Set 4

1)   The AUTONOMOUS_TRANSACTION pragma changes the way a subprogram works within a transaction.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
This pragma is marked to a subprogram so that it can do the SQL operations and commit or rollback these operations. That is why the AUTONOMOUS_TRANSACTION pragma changes the way a subprogram works within a transaction.


2)   __________ is a numeric expression that must return a value of type PLS_INTEGER,BINARY_INTEGER, or a value implicitly convertible to that datatype.

a. index
b. indicator_name
c. field_name
d. host_variable_name
Answer  Explanation 

ANSWER: index

Explanation:
No explanation is available for this question!


3)   Which statements execute a sequence of statements multiple times?

a. LOOP statement
b. NULL statement
c. MERGE statement
d. None of the above
Answer  Explanation 

ANSWER: LOOP statement

Explanation:
A loop helps us in executing a statement or a group of statement multiple times depending on the block of code.


4)   Which methods implement some internal logic for comparing two objects? For example, a rectangle is bigger than another rectangle if both its sides are bigger.

a. Order method
b. Map method
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Order method

Explanation:
ORDER method is the member method to order variables of an object type. The values of two objects are compared based on the criteria that we specify.


5)   The comparison methods are used for comparing objects. How many ways are available for comparing objects?

a. 4
b. 1
c. 2
d. 5
Answer  Explanation 

ANSWER: 2

Explanation:
There are 2 methods used for comparing objects they are
Map Method - It is a function implemented in such a way that its values depends depends upon the value of the attributes
Order Method - It implements some internal logic for comparing two objects.


6)   When implementing methods using PL/SQL, you cannot call a base or supertype object method with the super keyword or an equivalent method in a derived object.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


7)   For a user-defined exception, SQLCODE returns 1, and SQLERRM returns ___________.

a. “User-defined Exception”
b. 1
c. 0
d. None of the above
Answer  Explanation 

ANSWER: “User-defined Exception”

Explanation:
The SQLCODE is useful in an exception handler. SQLCODE is useful to the other exception handlers as it lets you identify the internal exception which is raised. The SQLERRM will return the user defined exception.


8)   Which of the following is handled with the help of exception-handling section in an PL/SQL block. For eg, SELECT INTO statement, which does not return any rows.

a. A runtime error
b. A syntax error
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: A runtime error

Explanation:
The exception-handling section is a special section of a PL/SQL block where the errors are specified.


9)   A package will have which of these mandatory parts?

a. Package specification
b. Package body or definition
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
A package has two mandatory parts:

1. Package Specification - This is the interface to the package. It declares the types,variables,constants,exceptions,cursors and the subprograms. It contains all information about the content of the package.
2. Package Body - It consists of all the codes for the methods declared in the package specification.


10)   Which collection method Returns the index number that precedes index n in a collection?

a. PRIOR(n)
b. LAST
c. LIMIT
d. COUNT
Answer  Explanation 

ANSWER: PRIOR(n)

Explanation:
The PRIOR(n) return the index number that precedes index n in PL/SQL table. If the value n has no predecessor then it returns null. the PRIOR and NEXT do not wrap from one end to the other.


11)   Subprograms let you extend the PL/SQL language. Which subprogram acts like new expressions and operators?

a. Procedures
b. Functions
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Functions

Explanation:
Functions in a subprogram act like new expressions and operators. A function computes a value in a subprogram. The function has a return clause.


12)   In which parameter mode Formal parameter acts like an initialized variable?

a. IN
b. OUT
c. IN OUT
d. None of the above
Answer  Explanation 

ANSWER: IN OUT

Explanation:
As the IN OUT parameter acts like an initialized variable it can be assigned a value and its value can be assigned to another value. We can use this IN OUT parameter as a normal parameter.


13)   Which attribute returns NULL?

a. %FOUND
b. %ISOPEN
c. %NOTFOUND
d. %ROWCOUNT
Answer  Explanation 

ANSWER: %FOUND

Explanation:
The %FOUND attribute returns null if the cursor is open but the fetch has not been executed.


14)   With PL/SQL, it is very simple to issue a query, retrieve each row of the result into a %ROWTYPE record, and process each row in a loop.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The %ROWTYPE record processes each row in a loop:

1. It includes the text of the query directly in the for loop
2. It creates a record with fields corresponding to the columns.
3. The fields of the records are inside the loop. The test, calculations, display outputs are stored in other place.


15)   You can use the BULK COLLECT INTO clause with the FETCH statement to store values from each column of a cursor in a separate collection.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The bulk binding binds a variable in a SQL statement to a collection of values. The FETCH statement supports the dynamic bulk binding.


16)   To process most dynamic SQL statements, you use the EXECUTE IMMEDIATE statement. To process a multi-row query (SELECT statement), which of these statements would you use?

a. OPEN-FOR
b. FETCH
c. CLOSE
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
Dynamic SQL is used to create general purpose,flexible applications so that the full text may be unknown at compilation. Hence, To process most dynamic SQL statements, you use the EXECUTE IMMEDIATE statement. To process a multi-row query (SELECT statement), we use the OPEN-FOR,FETCH,CLOSE statements.


17)   You can use the RETURNING BULK COLLECT INTO clause with the EXECUTE IMMEDIATE statement to store the results of which statements in a set of collections?

a. INSERT
b. UPDATE
c. DELETE
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
The bulk binding binds a variable in a SQL statement to a collection of values.


18)   Which of the following is a group of related data items stored in fields, each with its own name and datatype?

a. A Record
b. A Collection
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: A Record

Explanation:
A record is a data structure which can hold items of different types.


19)   Nested tables are a good choice when

a. The index values are not consecutive.
b. There is no set number of index values. However, a maximum limit is imposed.
c. You need to delete or update some elements, but not all the elements at once.
d. You would usually create a separate lookup table, with multiple entries for each row of the main table, and access it through join queries.
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
No explanation is available for this question!


20)   Associative arrays also known as index-by tables.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The associative arrays helps us to look up to the elements using arbitary numbers and strings for subscript values. They are similar to hash tables.


21)   Which type of cursor is automatically declared by Oracle every time an SQL statement is executed?

a. An Implicit
b. An Explicit
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: An Implicit

Explanation:
The implicit cursor are automatically created. We cannot control this cursor. This cursor is associated with the DML statements.


22)   An Explicit cursor is defined by the program for any query that returns more than one row of data.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
An explicit cursor is a user defined cursor and is used for gaining control over the context area. It is mostly used on the SELECT statement which returns more than one row.


23)   To handle raised exceptions, you write separate routines called exception handlers.

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
Once the exception handle run, the current block stops executing and the next block starts resuming. If there is no other block the control returns back to the host environment.


24)   What are the different datatypes that can be defined in a PL/SQL block?

a. Scalar
b. Composite
c. Reference
d. LOB
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
PL/SQL defines a wide variety of data types. It even lets you pre define the subtypes.


25)   The BINARY_INTEGER and PLS_INTEGER datatypes are not identical.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
The BINARY_INTEGER datatype is identical to PLS_INTEGER. PLS_INTEGER subtypes can also be regarded as a BINARY_INTEGER subtypes.


26)   Which of the following results are true, when a ROLLBACK statement is issued to the database, the transaction has ended?

a. All work done by the transaction is undone, as if it hadn't been issued.
b. Any locks acquired by the transaction are released.
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The undoing of all or some of the changes in a database during the current transaction is known as ROLLBACK. This statement is embedded as static SQL.


27)   PL/SQL Expressions are constructed using.

a. Operands
b. Operators
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The PL/SQL Expressions are a combination of operands and operators. They can even be constructed using a single of them.


28)   Which of the following are used for displaying output on a web page?

a. HTF
b. HTP
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
HTF and HTP are both HTML tags and they are used for creating we pages.


29)   Like all identifiers, the names of constants, variables, and parameters are case sensitive.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
Like all identifiers, the names of constants,variables, and parameters are not case sensitive.


30)   Cursor attributes are not affected by autonomous transactions.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The autonomous transactions allow to interfere in the working of triggers and cursors. The working of either does not change.