0% found this document useful (0 votes)
672 views

Nested Loops

The document contains a quiz with multiple choice questions about nested loops in PL/SQL. The first question asks how many lines of output will be displayed by a nested loop that iterates from 1 to 5 in the outer loop and 1 to 8 in the inner loop. The second question asks what statement should be used at a specified line ("Line A") to exit the outer loop of a nested loop structure. The third question asks what statement allows exiting the outer loop from within the inner loop at a specified point ("Point A") in a code block. The last few questions ask about labeling nested loops, the type of loop statement that should be used at a specified point, statements about nested loops,

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
672 views

Nested Loops

The document contains a quiz with multiple choice questions about nested loops in PL/SQL. The first question asks how many lines of output will be displayed by a nested loop that iterates from 1 to 5 in the outer loop and 1 to 8 in the inner loop. The second question asks what statement should be used at a specified line ("Line A") to exit the outer loop of a nested loop structure. The third question asks what statement allows exiting the outer loop from within the inner loop at a specified point ("Point A") in a code block. The last few questions ask about labeling nested loops, the type of loop statement that should be used at a specified point, statements about nested loops,

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Test: Quiz: Iterative Control: Nested Loops 1.

When the following code is executed, how many lines of output will be di splayed? BEGIN FOR i IN 1..5 LOOP FOR j IN 1..8 LOOP DBMS_OUTPUT.PUT_LINE(i || ',' || j); END LOOP; DBMS_OUTPUT.PUT_LINE(i); END LOOP; END; Mark for Review (1) Points 80 45 (*) 14 41

Correct 2. Look at the following code: DECLARE v_blue NUMBER(3) := 0; v_red NUMBER(3) := 0; BEGIN << blue >> LOOP v_blue := v_blue + 1; EXIT WHEN v_blue > 10; << red >> LOOP v_red := v_red + 1; EXIT WHEN v_red > 10; -- Line A END LOOP red; END LOOP blue; END; What should you code at Line A to exit from the outer loop? Mark for Review (1) Points EXIT; EXIT red;

EXIT <<blue>>; EXIT blue; (*)

Correct 3. What statement allows you to exit the outer loop at Point A in the follo wing block? DECLARE v_outer_done CHAR(3) := 'NO'; v_inner_done CHAR(3) := 'NO'; BEGIN LOOP -- outer loop ... LOOP -- inner loop ... ... -- Point A EXIT WHEN v_inner_done = 'YES'; ... END LOOP; ... EXIT WHEN v_outer_done = 'YES'; ... END LOOP; END; Mark for Review (1) Points EXIT AT v_outer_done = 'YES'; EXIT WHEN v_outer_done = 'YES'; (*) WHEN v_outer_done = YES EXIT; EXIT <<outer loop>>;

Incorrect. Refer to Section 4 Lesson 5. 4. What type of loop statement would you write for Point A? BEGIN FOR v_outerloop IN 1..3 LOOP -- Point A DBMS_OUTPUT.PUT_LINE('Outer loop is:'||v_outerloop|| ' and inner loop is: '||v_innerloop); END LOOP; END LOOP; END; Mark for Review (1) Points

WHILE v_innerloop <=5 LOOP FOR v_innerloop 1..5 LOOP (*) LOOP WHILE v_outerloop<v_innerloop LOOP

Incorrect. Refer to Section 4 Lesson 5. 5. Which one of these statements about using nested loops is true? Mark for Review (1) Points All the loops must be labelled The outer loop must be labelled, but the inner loop need not be labelled The outer loop must be labelled if you want to exit the outer loop from within the inner loop (*) Both loops can have the same label

Correct 6. What will be displayed when the following block is executed? DECLARE x NUMBER(6) := 0 ; BEGIN FOR i IN 1..10 LOOP FOR j IN 1..5 LOOP x := x+1 ; END LOOP; END LOOP; DBMS_OUTPUT.PUT_LINE(x); END; Mark for Review (1) Points 5 10

15 50 (*)

Correct

You might also like