Sie sind auf Seite 1von 5

1. What will be displayed when this block is executed?

DECLARE v_birthdate DATE; BEGIN IF v_birthdate < '01-JAN-2000' THEN DBMS_OUTPUT.PUT_LINE(' Born in the 20th century '); ELSE DBMS_OUTPUT.PUT_LINE(' Born in the 21st century '); END IF; END; Mark for Review (1) Points Born in the 20th century Born in the 21st century (*) Exception raised because no date given 2. You want to repeat a set of statements 100 times, incrementing a counter each time. What kind of PL/SQL control structure would you use? (1) Points IF...THEN...ELSE IF...THEN...ELSIF...ELSE CASE...WHEN...THEN A loop. (*) 3. What will be displayed when this block is executed? DECLARE v_bool1 BOOLEAN := NULL; v_bool2 BOOLEAN := NULL; v_char VARCHAR(10) := 'Start'; BEGIN IF (v_bool1 = v_bool2) THEN v_char:='Equal'; ELSE v_char:='Not equal'; END IF; DBMS_OUTPUT.PUT_LINE(v_char); END; Mark for Review

Mark for Review (1) Points Equal Not equal (*) Start Nothing will be displayed. The block will fail because you cannot compare two null values. 4. A basic loop is a type of control structure used to change the logical flow of statements in a PL/SQL block. True or False? (1) Points True (*) False 5. Which one of the following is correct syntax for an IF statement? (1) Points IF condition THEN DO statement1; statement2; END IF; IF condition THEN statement1; statement2; END IF; (*) IF condition THEN statement1; statement2; ENDIF; IF condition THEN statement1; AND statement2; END IF; 6. Which of the following statements are true about any of the PL/SQL conditional control structures such as IF ... , CASE ... and loops? (1) Points Mark for Review Mark for Review Mark for Review

They allow the programmer to use logical tests to determine which statements are executed and which are not. They allow a set of statements to be executed repeatedly (i.e. more than once). They determine a course of action based on conditions. All of the above. (*) 7. What will be displayed when this block is executed? DECLARE v_bool1 BOOLEAN := TRUE; v_bool2 BOOLEAN; v_char VARCHAR(4) := 'up'; BEGIN IF (v_bool1 AND v_bool2) THEN v_char:='down'; ELSE v_char:='left'; END IF; DBMS_OUTPUT.PUT_LINE(v_char); END; Mark for Review (1) Points up down left (*) null 8. What is wrong with the following trivial IF statement: IF (v_job='President') THEN v_salary := 10000; Mark for Review (1) Points IF and THEN must be on the same line: IF (v_job='President') THEN ... The condition should be coded: IF (v_job := 'President')

END IF; is missing (*) ELSE is missing 9. We want to execute one of three statements depending on whether the value in V_VAR is 10, 20 or some other value. What should be coded at Line A? IF v_var = 10 THEN statement1; -- Line A statement2; ELSE statement3; END IF; Mark for Review (1) Points ELSE IF v_var = 20 THEN ELSIF v_var = 20 ELSIF v_var = 20 THEN (*) IF v_var = 20 THEN 10. Name three types of control structures in PL/SQL. (Choose three) (1) Points (Choose all correct answers) LOOP statements (*) SELECT statements EXCEPTIONS IF statements (*) CASE statements (*) 11. Look at the following (badly written) code: age := 5; IF age<30 THEN mature := 'adult'; ELSIF age<22 THEN mature := 'teenager'; ELSIF age<13 THEN mature := 'child'; END IF; DBMS_OUTPUT.PUT_LINE(mature); Mark for Review

What will be displayed when this code is executed? Mark for Review (1) Points child teenager adult (*) adultteenagerchild

Das könnte Ihnen auch gefallen