Oracle Quiz Answers. Oracle Quiz Questions An asterisk (*) indicates a correct answer.
marți, 12 martie 2013
Section 4 Lesson 2: Conditional Control: Case Statements
Conditional Control: Case Statements
Section 1
1. How must you end a CASE expression? (1) Points
END; (*)
ENDIF;
END CASE;
ENDCASE;
2. Examine the following code:
DECLARE
v_a BOOLEAN;
v_b BOOLEAN := FALSE;
v_c BOOLEAN ;
BEGIN
v_c := (v_a AND v_b);
-- Line A
....
END;
What is the value of V_C at Line A?
(1) Points
True
False (*)
NULL
Undefined
3. What will be displayed when the following block is executed?
DECLARE
v_age1 NUMBER(3);
v_age2 NUMBER(3);
v_message VARCHAR2(20);
BEGIN
CASE
WHEN v_age1 = v_age2 THEN v_message := 'Equal';
WHEN v_age1 <> v_age2 THEN v_message := 'Unequal';
ELSE v_message := 'Undefined';
END CASE;
DBMS_OUTPUT.PUT_LINE(v_message);
END;
(1) Points
Equal
Undefined (*)
Unequal
Nothing will be displayed because V_MESSAGE is set to NULL.
4. Examine the following code:
DECLARE
v_score NUMBER(3);
v_grade CHAR(1);
BEGIN
v_grade := CASE v_score
-- Line A
....
The CASE expression must convert a numeric score to a letter grade: 90 -> A, 80 -> B, 70 -> C and so on. What should be coded at Line A?
(1) Points
WHEN 90 THEN grade := 'A'
WHEN 90 THEN v_grade := 'A';
WHEN 90 THEN 'A' (*)
WHEN 90 THEN 'A';
5. What will be displayed when the following block is executed?
DECLARE
v_age NUMBER(3);
v_gender VARCHAR2(6) := 'Female';
v_status VARCHAR2(20);
BEGIN
CASE
WHEN v_age >= 18 AND v_gender = 'Male' THEN v_status := 'Adult Male';
WHEN v_age >= 18 AND v_gender = 'Female' THEN v_status := 'Adult Female';
WHEN v_age < 18 AND v_gender = 'Male' THEN v_status := 'Junior Male';
WHEN v_age < 18 AND v_gender = 'Female' THEN v_status := 'Junior Female';
ELSE v_status := 'Other Value';
END CASE;
DBMS_OUTPUT.PUT_LINE(v_status);
END;
(1) Points
Adult Male
Junior Female
Other Value (*)
Nothing will be displayed because V_STATUS is set to NULL.
6. How must you end a CASE statement? (1) Points
END;
END CASE; (*)
END IF;
ENDCASE;
7. Examine the following code:
DECLARE
v_score NUMBER(3);
v_grade CHAR(1);
BEGIN
CASE v_score
-- Line A
....
The CASE statement must convert a numeric score to a letter grade: 90 -> A, 80 -> B, 70 -> C and so on.
What should be coded at Line A?
(1) Points
WHEN 90 THEN v_grade := 'A'
WHEN 90 THEN v_grade := 'A'; (*)
WHEN 90 THEN 'A'
WHEN 90 THEN 'A';
8. Look at the following code:
DECLARE
x BOOLEAN := FALSE;
y BOOLEAN := FALSE;
z BOOLEAN ;
BEGIN
z := (x OR NOT y);
-- Line A
....
END;
What is the value of Z at Line A?
(1) Points
True (*)
False
NULL
An error will occur because you cannot combine two Boolean variables using "NOT".
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu