Multiple choice technology databases

Declare a number := 5; b number := null; c number := 10; Begin if a > b AND a < c then a := c * a; end if; End; What will be the value of 'a' after execution?

  1. 50

  2. NULL

  3. 5

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The key concept here is how NULL behaves in PL/SQL comparisons. Any comparison with NULL returns NULL (unknown), not true or false. Since variable b is NULL, the expression 'a > b' evaluates to NULL, making the entire AND condition NULL. Because the condition is not true, the IF block doesn't execute, and 'a' remains unchanged at its initial value of 5. Therefore option C (5) is correct.

AI explanation

To determine the value of 'a' after execution, let's go through the code step by step:

  1. Declare the variables:

    • a = 5
    • b = null
    • c = 10
  2. Evaluate the condition: a &gt; b AND a &lt; c

Since a is not null and satisfies both conditions (5 &gt; null and 5 &lt; 10), the condition evaluates to true.

  1. Execute the code within the if statement: a := c * a

Update the value of a to 10 * 5 = 50.

Therefore, the value of 'a' after execution will be 50.

The correct answer is A) 50.