Oracle Quiz Answers. Oracle Quiz Questions An asterisk (*) indicates a correct answer.
marți, 12 martie 2013
Section 4 Lesson 1: Conditional Control: IF Statements
Conditional Control: IF Statements
Section 1
1. 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 (*)
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. 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
4. 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);
What will be displayed when this code is executed?
(1) Points
child
teenager
adult (*)
adultteenagerchild
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. 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;
(1) Points
ELSE IF v_var = 20 THEN
ELSIF v_var = 20
ELSIF v_var = 20 THEN (*)
IF v_var = 20 THEN
7. 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;
(1) Points
Born in the 20th century
Born in the 21st century (*)
Exception raised because no date given
8. Which of the following statements are true about any of the PL/SQL conditional control structures such as IF ... , CASE ... and loops? (1) Points
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. (*)
9. What is wrong with the following trivial IF statement:
IF (v_job='President')
THEN v_salary := 10000;
(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
10. 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;
(1) Points
Equal
Not equal (*)
Start
Nothing will be displayed. The block will fail because you cannot compare two null values.
11. 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;
(1) Points
up
down
left (*)
null
Abonați-vă la:
Postare comentarii (Atom)
Niciun comentariu:
Trimiteți un comentariu