Вы находитесь на странице: 1из 4

Test: Quiz: Conditional Control: Case Statements 1.

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? Mark for Review (1) Points WHEN 90 THEN grade := 'A' WHEN 90 THEN v_grade := 'A'; WHEN 90 THEN 'A' (*) WHEN 90 THEN 'A';

Correct 2. How must you end a CASE expression? (1) Points END; (*) ENDIF; END CASE; ENDCASE; Mark for Review

Correct 3. 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? Mark for Review (1) Points WHEN 90 THEN v_grade := 'A' WHEN 90 THEN v_grade := 'A'; (*) WHEN 90 THEN 'A' WHEN 90 THEN 'A';

Correct 4. 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'; <br /> WHEN v_age < 18 AND v_gender = 'Female' THEN v_status := 'Junior Female'; < br /> ELSE v_status := 'Other Value'; END CASE; DBMS_OUTPUT.PUT_LINE(v_status); END; Mark for Review (1) Points Adult Male Junior Female Other Value (*) Nothing will be displayed because V_STATUS is set to NULL.

Correct 5. 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? Mark for Review (1) Points True (*) False NULL An error will occur because you cannot combine two Boolean variables usi ng "NOT".

Correct 6. 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; Mark for Review (1) Points Equal Undefined (*) Unequal Nothing will be displayed because V_MESSAGE is set to NULL.

Correct 7. 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? Mark for Review (1) Points True False (*) NULL Undefined

Correct 8. How must you end a CASE statement? (1) Points END; END CASE; (*) END IF; ENDCASE; Mark for Review

Correct

Вам также может понравиться