PL/SQL Test Questions Set 3

1)   Which of the following is used for reading and writing operating-system files?

a. UTL_FILE
b. UTL_HTTP
c. UTL_SMTP
d. None of the above
Answer  Explanation 

ANSWER: UTL_FILE

Explanation:
UTL_FILE helps the PL/SQL programs read and write operating system text files. It provides a restricted version of the operating system stream file I/O.


2)   Which error occurs while the program is running and cannot be detected by the PL/SQL compiler?

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

ANSWER: Runtime error

Explanation:
A software or a hardware problem that prevents a program from working correctly is known as a runtime error. These errors might cause to lose information in the file we are working on.


3)   Which keyword is used instead of the assignment operator to initialize variables?

a. NOT NULL
b. DEFAULT
c. %TYPE
d. %ROWTYPE
Answer  Explanation 

ANSWER: DEFAULT

Explanation:
Using the default value for a variable will give it a typical value. The value for that variable will be fixed.


4)   PL/SQL programs are written as lines of text using a specific set of characters.

a. Upper- and lower-case letters A .. Z and a .. z
b. Numerals 0 .. 9
c. Symbols ( ) + - * / < > = ! ~ ^ ; : . ' @ % , " # $ & _ | { } ? [ ]
d. Tabs, spaces, and carriage returns
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
PL/SQL is not a case-sensitive language. The character set has some specific set of characters which are used for the writing PL/SQL programs.


5)   How many bytes does each character in the AL16UTF16 encoding take up?

a. 1
b. 2
c. 3
d. 6
Answer  Explanation 

ANSWER: 2

Explanation:
AL16UTF16 comes with a fixed width that is 2 bytes. They are used when the storage requirement is high otherwise the bytes get wasted.


6)   LOB locators are values, which specify the location of the large object.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
A LOB data type is given to any column of a table the values that are stored for references are known as LOB locators which in turn help in specifying the location of large objects.


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

a. EXIT
b. LOOP
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: LOOP

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


8)   Oracle predefined errors are not associated with specific error codes.

a. True
b. False


Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


9)   Which of the following cannot be used with associative arrays?

a. EXTEND
b. TRIM
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The associative arrays are sets of key value pairs where each key is unique and used to locate a corresponding value in the array.


10)   In the Restrictions on Record Inserts and Updates, which of the following are not supported?

a. Nested record types
b. Functions that return a record
c. Record inserts and updates using the EXECUTE IMMEDIATE statement
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
The restrictions on the record are made on the DML statements. Some of the DML statements are restricted too.


11)   By using which clause, the mode is OUT, so you cannot specify a parameter mode for output bind arguments?

a. USING Clause
b. RETURNING INTO Clause
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: RETURNING INTO Clause

Explanation:
By using the USING clause the default mode is IN, so we need not specify a parameter mode for the input bind arguements. With the RETURNING INTO clause the mode is OUT so we cannot specify a parameter mode for output bind arguements.


12)   You can use the BULK COLLECT INTO clause with the EXECUTE IMMEDIATE statement to store values from each column of a query's result set in a separate collection.

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
The BULK sql passes an entire collection to and fro. The BULK COLLECT INTO clause is used to execute the statements immediately.


13)   Which of the following returns all distinct rows selected by either query?

a. INTERSECT
b. MINUS
c. UNION
d. UNION ALL
Answer  Explanation 

ANSWER: UNION

Explanation:
The union operator is used to combine result set of two or more select statements. It avoids duplication.


14)   Which statements are used to control a cursor variable?

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

ANSWER: All mentioned above

Explanation:
There are three statements used to control a cursor variable:
1. OPEN-FOR - open a cursor variable for multi-row query
2. FETCH - it fetches the rows for the result set
3. CLOSE - when all the rows are processed the cursor variable is closed.


15)   What is the maximum number of triggers that can apply to a single table?

a. 14
b. 10
c. 12
d. 16
Answer  Explanation 

ANSWER: 12

Explanation:
We can have N number of triggers on a table but the maximum type of triggers on a single table can be 3*2*2=12 that is the division is done as
Insert/Update/Delete= 3
Before/After= 2
Row Level/Statement Level=2


16)   The variables or expressions passed from the calling subprogram are -

a. Actual Parameters
b. Formal Parameters
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Actual Parameters

Explanation:
Variables which are declared in a subprogram specified and referred to in the subprogram body are formal parameters.
Variables or the expressions which are passed from the calling subprograms are actual parameters.


17)   Subprograms are named PL/SQL blocks that can be called with a set of parameters.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
There are two types of subprograms procedures and functions. The procedure is used to perform an action and the function is used to compute a value.


18)   Which of the following is not a schema object?

a. Packages
b. Indexes
c. Public Synonyms
d. Triggers
Answer  Explanation 

ANSWER: Public Synonyms

Explanation:
A alternative name for a table,view etc is known as a synonym. A synonym which is accessible to all the users is known as a public synonym. Hence, a public synonym is not a schema object.


19)   Which package lets PL/SQL programs read and write operating system (OS) text files?

a. UTL_HTTP
b. UTL_FILE
c. UTL_SMTP
d. None of the above
Answer  Explanation 

ANSWER: UTL_FILE

Explanation:
UTL_FILE helps the PL/SQL programs read and write operating system text files. It provides a restricted version of the operating system stream file I/O.


20)   You can pass parameters to procedures or functions in a package.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The parameters can be passed as default also to the procedures and the functions.


21)   When creating a function, in which section will you typically find a return key word?

a. Header Only
b. Declarative
c. Executable and Header
d. Executable and exception handling
Answer  Explanation 

ANSWER: Executable and Header

Explanation:
The return keyword is an executable statement. It is mandatory to write this keyword in a function.


22)   Which of the following returns the current error message text?

a. SQLERRM
b. SQLCODE
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: SQLERRM

Explanation:
Using this function the associated error message with the most recent raised error exception is displayed. The exception handling section will display this function.


23)   Which datatypes are PL/SQL-only datatypes that are more efficient than the SQL datatypes NUMBER or INTEGER for integer arithmetic?

a. PLS_INTEGER
b. BINARY_INTEGER
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The BINARY_INTEGER is used to store signed integers. They require less storage than the number values. Arithmetic operations work faster.
PLS_INTEGER have the same advantages as the BINARY_INTEGER.


24)   In which binding operation a database value is assigned to a PL/SQL variable or a host variable by the RETURNING clause of an INSERT, UPDATE, or DELETE statement.

a. out-bind
b. in-bind
c. define
d. None of the above
Answer  Explanation 

ANSWER: out-bind

Explanation:
The INSERT,UPDATE,DELETE statements have the out bind variables. They are bulk binded with the RETURNING BULK COLLECT INTO clause of EXECUTE IMMEDIATE.


25)   Which datatypes make it practical to write PL/SQL programs to do number-crunching, for scientific applications involving floating-point calculations.

a. BINARY_FLOAT
b. BINARY_DOUBLE
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
Explanation: The BINARY_FLOAT and BINARY_DOUBLE require less storage space which make them more efficient. They do not represent fractional values precisely so they should not be used where accuracy is needed.