PL/SQL Test Questions Set 2

1)   PL/SQL provides a feature to handle the Exceptions which occur in a PL/SQL Block known as exception Handling.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
An exception handling block is used so that we can avoid the errors in the program. The exception message consists of
1. Type of exception
2. An error code
3. A message


2)   Which Exception is also known as Oracle named exception handler?

a. Predefined Exception
b. Internal Exception
c. User defined Exception
d. None of the above
Answer  Explanation 

ANSWER: Predefined Exception

Explanation:
A predefined exception is the one which is executed whenever a program violates any database rule. Example of this type of exception can be the exception NO_DATA_FOUND.


3)   WRAP command is used to encrypt a PL/SQL application.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The WRAP command is used while we are delivering a PL/SQL application without exposing the source code. Syntax for this would be
wrap iname=[file] oname=[file]


4)   Which Package lets you use database triggers to alert an application when specific database values change?

a. DBMS_OUTPUT
b. DBMS_ALERT
c. DBMS_PIPE
d. All mentioned above
Answer  Explanation 

ANSWER: DBMS_ALERT

Explanation:
It helps in the asynchronous notification of the database events. The DBMS_ALERT uses the constants.


5)   PL/SQL packages are schema objects that group logically related PL/SQL types, variables and subprograms.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
A package is divided into 2 parts a specification and a body. The specification is an interface to the package and it declares the types,variables,subprograms etc. which can be referenced from outside the package. The body consists of queries for the cursor and the code for subprograms.


6)   Which statement lets you create standalone functions that are stored in an Oracle database?

a. SQL CREATE PROCEDURE
b. SQL CREATE FUNCTION
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: SQL CREATE FUNCTION

Explanation:
The create function helps in creating a function.


7)   Which parameter acts like a constant inside the subprogram?

a. IN
b. OUT
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: IN

Explanation:
The IN parameter are used to send the values to the stored procedures.


8)   Which of the following is used to define code that is executed / fired when certain actions or event occur?

a. Replace
b. Keyword
c. Trigger
d. Cursor
Answer  Explanation 

ANSWER: Trigger

Explanation:
The stored programs which execute automatically or when some events occur are known as triggers. The triggers can be defined on a table,view,schema or on a database.


9)   Which Operator Returns TRUE if a subquery returns at least one row?

a. EXISTS
b. IN
c. IS NULL
d. LIKE
Answer  Explanation 

ANSWER: EXISTS

Explanation:
The EXISTS condition is used by a subquery and is considered if the subquery atleast returns one row.


10)   How many attributes does every explicit cursor and cursor variable have?

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

ANSWER: 4

Explanation:
The 4 attributes are: %FOUND, %ISOPEN %NOTFOUND, and %ROWCOUNT. When these attributes are appended with the cursor or the cursor variable they return useful information about the execution of a data manipulation statement.


11)   The DBMS_SQL package should be used in which of the following situations?

a. 15. There is an unknown number of input or output variables, such as the number of column values returned by a query, that are used in a dynamic SQL statement.
b. The dynamic code is too large to fit inside a 32K bytes VARCHAR2 variable.
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The DBMS_SQL package provides an interface to use dynamic SQL to parse any data manipulation language (DML) or data definition language (DDL) statement using PL/SQL


12)   A function called from SQL statements must obey certain rules meant to control side effects.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


13)   Collection is an ordered group of elements, all of the same type.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
Internal components that can be manipulated individually such as the elements of an array,record or table is known as collections.


14)   Arrays in other languages become varrays in PL/SQL.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
A varray can store a fixed sequential collection of elements of the same type. It is used to store ordered collection of data.


15)   How many nested IF clauses can be included within an IF clause?

a. 1
b. 0
c. 15
d. Any number
Answer  Explanation 

ANSWER: Any number

Explanation:
PL/SQL supports the nested IF control structure. Hence, we can include any number of IF clauses.


16)   In PL/SQL, a warning or error condition is called an exception.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
An error condition during a program is known as an exception. The exception block is used in the program and an appropriate action is taken against the error condition.
There are 2 types of exceptions
1. System-defined exceptions
2. User-defined exceptions.


17)   Which datatypes can be used with a RECORD Type?

a. NUMBER,VRCHAR2
b. %TYPE,OR %ROWTYPE
c. REF,CURSOR
d. BOTH A & B
e. BOTH B & C
Answer  Explanation 

ANSWER: BOTH A & B

Explanation:
A record is a data structure that can hold data items of different kinds. It consists of different fields similar to a row of a database table.


18)   SIGNTYPE lets you restrict an integer variable to the values -1, 0, and 1, which is useful in programming tri-state logic.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
Signtype is a subtype of binary integer. It requires less storage.


19)   Is it possible to define a NOT NULL field in a record?

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
The not null field helps us return all the not null records. It is like giving a condition to the block or the expression.


20)   PL/SQL keywords are not case-sensitive.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The lower-case letters are equal to the corresponding upper-case letters except for the string and the character literals. Hence, we say that the PL/SQL keywords are not case-sensitive.


21)   PL/SQL stands for -

a. Programming Language/SQL
b. Procedural Language/SQL
c. Portable Language/SQL
d. None of the above
Answer  Explanation 

ANSWER: Procedural Language/SQL

Explanation:
No explanation is available for this question!


22)   Pragmas are processed at ___________ .

a. Run time
b. Compile time
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Compile time

Explanation:
PRAGMA refers to a compiler directive it is used to provide an instruction to the compiler. They are processed at compile time where the necessary information is passed to the compiler. they are not processed at runtime.


23)   Which statement chooses from a sequence of conditions, and executes a corresponding statement?

a. CASE Statement
b. CLOSE Statement
c. COMMIT Statement
d. None of the above
Answer  Explanation 

ANSWER: CASE Statement

Explanation:
The CASE statement selects one sequence of statements to execute. To select a sequence it uses a selector. It is an expression, whose value is used to select one of the several alternative.


24)   Constructors are functions that return a new object as its value.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
A constructor has the same name as the object name. Constructor method defined by the system is applicable to each and every object.


25)   An object type can represent any real-world entity.

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!