You are on page 1of 4

Test: Quiz: Iterative Control: Basic Loops 1. What will be displayed when this block is executed?

DECLARE v_count NUMBER := 10; v_result NUMBER; BEGIN LOOP v_count := v_count - 1; EXIT WHEN v_count < 5; v_result := v_count * 2; END LOOP; DBMS_OUTPUT.PUT_LINE(v_result); END; Mark for Review (1) Points 8 10 (*) 12 NULL

Correct 2. How many EXIT statements can be coded inside a basic loop? Review (1) Points None. One only. Two. As many as you need, there is no limit. (*) Mark for

Correct 3. Which kind of loop is this? i := 10; LOOP i := i + 1; EXIT WHEN i > 30; END LOOP;

Mark for Review (1) Points A FOR loop. A WHILE loop. A basic loop. (*) An infinite loop. A nested loop.

Correct 4. Examine the following code: DECLARE v_count NUMBER := 0; v_string VARCHAR2(20); BEGIN LOOP v_string := v_string || 'x'; IF LENGTH(v_string) > 10 THEN EXIT; END IF; v_count := v_count + 1; END LOOP; DBMS_OUTPUT.PUT_LINE(v_count); END; What will be displayed when this block is executed? Mark for Review (1) Points 9 10 (*) 11 xxxxxxxxxxx

Correct 5. You want to calculate and display the multiplication table for "sevens" : 7x1=7, 7x2=14, 7x3=21 and so on. Which kind of PL/SQL construct is best for th

is? Mark for Review (1) Points A loop (*) A CASE statement IF ... END IF; A Boolean variable.

Correct 6. Look at this code: DECLARE v_bool BOOLEAN := TRUE; v_date DATE; BEGIN LOOP EXIT WHEN v_bool; SELECT SYSDATE INTO v_date FROM dual; END LOOP; END; How many times will the SELECT statement execute? Mark for Review (1) Points Once. Twice. Never (the SELECT will not execute at all) (*) An infinite number of times because the EXIT condition will never be tru e

Correct 7. For which one of these tasks should you use a PL/SQL loop? Review (1) Points Updating the salary of one employee. Executing the same set of statements repeatedly until a condition become Mark for

s true. (*) Deciding whether a value is within a range of numbers. Making a decision based on whether a condition is true or not.

Correct 8. What are the three kinds of loops in PL/SQL? (1) Points ascending, descending, unordered infinite, finite, recursive IF, CASE, LOOP FOR, WHILE, basic (*) Mark for Review

Correct

You might also like