Oracle Quiz Answers. Oracle Quiz Questions An asterisk (*) indicates a correct answer.
marți, 12 martie 2013
Section 4 Lesson 3: Iterative Control: Basic Loops
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;
(1) Points
8
10 (*)
12
NULL
2. For which one of these tasks should you use a PL/SQL loop? (1) Points
Updating the salary of one employee.
Executing the same set of statements repeatedly until a condition becomes true. (*)
Deciding whether a value is within a range of numbers.
Making a decision based on whether a condition is true or not.
3. 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?
(1) Points
Once.
Twice.
Never (the SELECT will not execute at all) (*)
An infinite number of times because the EXIT condition will never be true
4. Which kind of loop is this?
i := 10;
LOOP
i := i + 1;
EXIT WHEN i > 30;
END LOOP;
(1) Points
A FOR loop.
A WHILE loop.
A basic loop. (*)
An infinite loop.
A nested loop.
5. 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?
(1) Points
9
10 (*)
11
xxxxxxxxxxx
6. 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 this? (1) Points
A loop (*)
A CASE statement
IF ... END IF;
A Boolean variable.
7. What are the three kinds of loops in PL/SQL? (1) Points
ascending, descending, unordered
infinite, finite, recursive
IF, CASE, LOOP
FOR, WHILE, basic (*)
8. How many EXIT statements can be coded inside a basic loop? (1) Points
None.
One only.
Two.
As many as you need, there is no limit. (*)
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu