Oracle Quiz Answers. Oracle Quiz Questions An asterisk (*) indicates a correct answer.
marți, 12 martie 2013
Section 4 Lesson 4: Iterative Control: While and For Loops
Iterative Control: While and For Loops
1. Look at the following code fragment:
i := 2;
WHILE i < 3 LOOP
i := 4;
DBMS_OUTPUT.PUT_LINE('The counter is: ' || i);
END LOOP;
How many lines of output will be displayed?
(1) Points
No lines
One line (*)
Two lines
The block will fail because you cannot use DBMS_OUTPUT.PUT_LINE inside a loop.
2. Look at the following block:
DECLARE
v_date DATE := SYSDATE;
BEGIN
WHILE v_date < LAST_DAY(v_date) LOOP
v_date := v_date + 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE(v_date);
END;
If today's date is 17th April 2007, what will be displayed when this block executes?
(1) Points
01-MAY-07
31-DEC-07
4/30/2007 (*)
4/17/2007
3. Which statement best describes when a FOR loop should be used? (1) Points
When an EXIT WHEN statement must be coded.
When an implicitly declared counter must increase by 1 in each iteration of the loop. (*)
When we want to exit from the loop when a Boolean variable becomes FALSE.
When the statements inside the loop must execute at least once.
4. You should use a WHILE loop when the number of iterations of the loop is known in advance. True or False? (1) Points
True
False (*)
5. Look at this code fragment: FOR i IN 1 .. 3 LOOP i := 4; DBMS_OUTPUT.PUT_LINE('The counter is: ' || i); END LOOP; How many lines of output will be displayed? (1) Points
One
Three
Four
The block will fail because you cannot change the value of i inside the loop. (*)
6. In a FOR loop, an explicitly declared counter is automatically incremented by 1 for each iteration of the loop. True or False? (1) Points
True
False (*)
7. In a WHILE loop, the controlling condition is checked at the start of each iteration. True or False? (1) Points
True (*)
False
8. You want a loop that counts backwards from 10 through 1. How do you code that? (1) Points
FOR i IN 10 .. 1 LOOP
FOR i IN 1 .. 10 BY -1 LOOP
FOR i IN REVERSE 1 .. 10 LOOP (*)
FOR i IN REVERSE 10 .. 1 LOOP
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu