PL/SQL Test Questions Set 5

1)   How many bytes does each character in the UTF8 encoding take up?

a. 1
b. 2
c. 3
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
The UTF-8 is capable of encoding all characters, code points in unicode.


2)   Use the ROWID datatype only for backward compatibility with old applications. For new applications, use the UROWID datatype.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
The ROWID stores the binary values called the row ids. It represents the storage address. The UROWID stores the physical, logical, or foreign row ids


3)   Which datatype is not allowed in the definition of PL/SQL record?

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

ANSWER: A Collection

Explanation:
An ordered group of elements all of the same type is known as a collection.


4)   In the SQL Cursor, which attribute is TRUE when a cursor has some remaining rows to fetch, and FALSE when a cursor has no rows left to fetch?

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

ANSWER: %FOUND

Explanation:
The %FOUND is a cursor attribute. The return value will be TRUE if the DML statements have an affect on atleast one row and the SELECT...INTO statement also returns atleast one row.
The return value will be FALSE if the DML statements do not affect any row and the SELECT...INTO statement does not return any row.


5)   For which Exception, if a SELECT statement attempts to retrieve data based on its conditions, this exception is raised when no rows satisfy the SELECT criteria?

a. TOO_MANY_ROWS
b. NO_DATA_FOUND
c. VALUE_ERROR
d. DUP_VAL_ON_INDEX
Answer  Explanation 

ANSWER: NO_DATA_FOUND

Explanation:
The NO_DATA_FOUND exception is raised when the FETCH statement is not able to find the relevant data that we have asked for.


6)   In the PL/SQL block below, how many rows will be inserted in the messages table?

DECLARE
v_start_sales NUMBER := 2;
v_end_sales NUMBER := 100;
BEGIN
FOR i IN v_start_sales..v_end_sales LOOP
INSERT INTO messages(msgid)
VALUES v_start_sales;
END LOOP;
END;


a. 0
b. 99
c. 1
d. 100
Answer  Explanation 

ANSWER: 99

Explanation:
The output will be 99 because the loop will start with 2 as v_start_sales NUMBER is declared as 2. The loop will go on until it reaches 100 as the v_end_sales NUMBER is declared as 100. So the loop will start with 2 and go on till 100. Its total comes to 99.


7)   Which collection types is also known as index-by tables, lets you look up elements using arbitrary numbers and strings for subscript values?

a. Associative arrays
b. Nested tables
c. Varrays
d. None of the above
Answer  Explanation 

ANSWER: Associative arrays

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.


8)   Assigning a value to a collection element can cause exceptions, such as

a. If the subscript is NULL or is not convertible to the right datatype, PL/SQL raises the predefined exception VALUE_ERROR. Usually, the subscript must be an integer. Associative arrays can also be declared to have VARCHAR2 subscripts.
b. If the subscript refers to an uninitialized element, PL/SQL raises SUBSCRIPT_BEYOND_COUNT.
c. If the collection is atomically null, PL/SQL raises COLLECTION_IS_NULL.
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
No explanation is available for this question!


9)   Nested tables can be sparse: you can delete arbitrary elements, rather than just removing an item from the end.

a. Yes
b. No


Answer  Explanation 

ANSWER: Yes

Explanation:
The nested tables and the varrays are the one that we need to select upon. A nested table is a dimensional array with arbitary elements.


10)   Which of the following retains duplicate rows in the result of a query or in an aggregate expression?

a. ALL
b. DISTINCT
c. PRIOR
d. None of the above
Answer  Explanation 

ANSWER: ALL

Explanation:
The ALL compares one value to every other value in the list and is TRUE if all the comparisons are true.


11)   Which operations cannot be performed on cursor expressions?

a. BIND
b. EXECUTE
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
We can use a cursor in the block. However, there are certain restrictions on the cursor expressions. One of the restriction is that we cannot perform BIND and EXECUTE operations on the cursor expressions.


12)   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.


13)   PL/SQL has two types of subprograms, procedures and functions. Which subprogram is used to compute a value?

a. Procedure
b. Function
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Function

Explanation:
A function is same as a procedure but a procedure does not return a value whereas a function returns a value.


14)   Which is a procedural extension of Oracle- SQL that offers language constructs similar to those in imperative programming languages?

a. PQL
b. Advanced SQL
c. PL/SQL
d. SQL
Answer  Explanation 

ANSWER: PL/SQL

Explanation:
PL/SQL is a language formed by combining SQL and the procedural features of programming language. It was developed to enhance the capabilities of SQL. It is one of the key programming language.


15)   In which subprogram a RETURN statement does not return a value and so cannot contain an expression?

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

ANSWER: In Procedures

Explanation:
Procedures are the subprograms which do not return a value directly because they are mainly used for performing actions.


16)   Which of the following combines the data manipulating power of SQL with the data processing power of Procedural languages?

a. PQL
b. Advanced SQL
c. PL/SQL
d. SQL
Answer  Explanation 

ANSWER: PL/SQL

Explanation:
PL/SQL is a language formed by combining SQL and the procedural features of programming language. It was developed to enhance the capabilities of SQL. It is one of the key programming language.


17)   The constructs of a procedure, function or a package are ________ .

a. Variables and Constants
b. Cursors
c. Exceptions
d. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
No explanation is available for this question!


18)   Any subprogram not in the package specification but coded in the package body is called a ___________ .

a. Public object
b. Private object
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Private object

Explanation:
Private objects are the one which are not visible to the applications outside the package.


19)   Which of the following are the advantages of PL/SQL Packages?

a. Modularity
b. Easier Application Design
c. Information Hiding
d. Added Functionality,Better Performance
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
No explanation is available for this question!


20)   In internal exception oracle raises the exception for you implicitly. You still need to declare the exception and handle it, but you don’t need to raise it.

a. True
b. False


Answer  Explanation 

ANSWER: True

Explanation:
In the internal exception a technique is used to bind a numbered exception handler using the PRAGMA_EXCEPTION_INIT() which is a compiler direction. This PRAGMA calls a pre-compiler which binds the exception handler. The EXCEPTION_INIT() takes in the parameters.


21)   Which PL/SQL warning categories gives Messages for conditions that do not have an effect on performance or correctness, but that you might want to change to make the code more maintainable, such as unreachable code that can never be executed?

a. PERFORMANCE
b. SEVERE
c. INFORMATIONAL
d. All mentioned above
Answer  Explanation 

ANSWER: INFORMATIONAL

Explanation:
No explanation is available for this question!


22)    ________ does not correlate with an oracle error, instead, user_define exceptions usually enforce business rules in situations in which an oracle error would not necessarily occur

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

ANSWER: User defined Exception

Explanation:
PL/SQL allows to raise our own exceptions. A user defined exception is declared explicitly using the raise statement.


23)   Which keyword and parameter used for declaring an explicit cursor?

a. constraint
b. cursor_variable_declaration
c. collection_declaration
d. cursor_declaration
Answer  Explanation 

ANSWER: cursor_declaration

Explanation:
cursor_declaration

cursor - This means it will have the name of the explicit cursor that we are declaring and will define it later in the same block,subprogram or package. It can be any identifier except for the reserved words. It follows the same scoping rules as the variables.


24)   For which of the following can pragma be applied?

a. Top-level (not nested) anonymous PL/SQL blocks
b. Local, standalone, and packaged functions and procedures
c. Methods of a SQL object type
d. Database triggers
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
The pragma is marked to a subprogram so that it can do the SQL operations and commit or rollback these operations. That is why a pragma can be applied to all the options mentioned above.


25)   Which of the following declares an instance of an object type?

a. record_declaration
b. procedure_declaration
c. object_declaration
d. None of the above
Answer  Explanation 

ANSWER: object_declaration

Explanation:
An object can represent a real world entity.


26)   Which is a schema object that groups logically related PL/SQL types, items, and subprograms?

a. Package Declaration
b. Object_type declaration
c. Procedure declaration
d. None of the above
Answer  Explanation 

ANSWER: Package Declaration

Explanation:
Packages have 2 parts

1. Package specification – It is an interface to the package. It declares the variables, types,constants,cursors and subprograms.
2. Package body or specification – It includes the various code lines in it