Anda di halaman 1dari 4

Test: Recognizing the Scope of Exceptions: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indica
tes a correct answer.
Section 1
(Answer all questions in this section)
1. Predefined Oracle Server exceptions such as NO_DATA_FOUN
D can be raised automatically in inner blocks and handled in outer blocks. True
or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
2. Non-predefined Oracle Server errors (associated with Ora
cle error numbers by PRAGMA EXCEPTION_INIT) can be declared and raised in inner
blocks and handled in outer blocks. True or False? Mark for Review
(1) Points
True
False (*)
Correct Correct
3. What will happen when the following code is executed?
DECLARE
e_outer_excep EXCEPTION;
BEGIN
DECLARE
e_inner_excep EXCEPTION;
BEGIN
RAISE e_outer_excep;
END;
EXCEPTION
WHEN e_outer_excep THEN
DBMS_OUTPUT.PUT_LINE('Outer raised');
WHEN e_inner_excep THEN
DBMS_OUTPUT.PUT_LINE('Inner raised');
END;
Mark for Review
(1) Points
The code will execute successfully and 'Outer Raised' will be displayed.
The code will propagate the e_outer_excep back to the calling environmen
t (Application Express).
The code will fail to compile because e_inner_excep was declared but nev
er RAISEd.
The code will fail to compile because e_inner_excep cannot be referenced
in the outer block. (*)
Correct Correct
4. What will happen when the following code is executed?
DECLARE
e_excep1 EXCEPTION;
e_excep2 EXCEPTION;
BEGIN
RAISE e_excep1;
EXCEPTION
WHEN e_excep1 THEN BEGIN
RAISE e_excep2; END;
END;
Mark for Review
(1) Points
It will compile successfully and return an unhandled e_excep2 to the cal
ling environment. (*)
It will fail to compile because you cannot have a subblock inside an exc
eption section.
It will fail to compile because you cannot declare more than one excepti
on in the same block.
It will fail to compile because e_excep1 is out of scope in the subblock
.
Correct Correct
5. There are three employees in department 90. What will be
displayed when this code is executed?
DECLARE
v_last_name employees.last_name%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE('Message 1');
BEGIN
SELECT last_name INTO v_last_name
FROM employees WHERE department_id = 90;
DBMS_OUTPUT.PUT_LINE('Message 2');
END;
DBMS_OUTPUT.PUT_LINE('Message 3');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Message 4');
END;
Mark for Review
(1) Points
Message 1
Message 3
Message 4
Message 1
Message 4
(*)
Message 1
An unhandled exception will be propagated back to the calling environmen
t.
None of the above
Correct Correct
6. What will be displayed when the following code is execut
ed?
<<outer>>
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 25;
DECLARE
v_myvar NUMBER := 100;
BEGIN
outer.v_myvar := 30;
v_myvar := v_myvar / 0;
outer.v_myvar := 35;
END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END;
Mark for Review
(1) Points
30 (*)
35
40
25
100
Correct Correct