In a PL/SQL block, a variable is declared as NUMBER without an initial value. What will its value be when it is first used in the executable section of the PL/SQL block?

  1. 0

  2. NULL

  3. Results in a compilation error

  4. An exception will be raised


Correct Option: B
Explanation:

To solve this question, the user needs to know what happens when a variable is declared in PL/SQL without an initial value.

The answer is:

B. NULL

If a variable is declared in PL/SQL without an initial value, its value will be NULL when it is first used in the executable section of the PL/SQL block. This means that the variable does not have a value assigned to it yet. If the variable is used in an expression or operation, it will result in a NULL value, which can cause unexpected behavior in your code.

Option A is incorrect because the variable will not have a value of 0 by default.

Option C is incorrect because declaring a variable without an initial value is legal and will not result in a compilation error.

Option D is incorrect because an exception will not be raised when a variable is declared without an initial value. It will simply have a value of NULL.

Find more quizzes: