PL/SQL Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to PL/SQL. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following is not a PL/SQL unit?

A - Table

B - Type

C - Trigger

D - Package

Answer : A

Q 3 - What is the output of the following code?

DECLARE
   x number := 4;
BEGIN
   LOOP
      dbms_output.put_line(x);
      x := x + 1;
      exit WHEN x > 5;
   END LOOP;
      dbms_output.put_line(x);
END;

A - 4

     5

     6

B - 4

     5

C - 4

D - None of the above.

Answer : A

Q 4 - Consider a variable named greetings declared as −

greetings varchar2(11) := 'Hello World';

What will be the output of the code snippet

dbms_output.put_line ( SUBSTR (greetings, 7, 5));

A - World

B - Hello

C - orld

D - None of the above.

Answer : A

Q 5 - What would be the output of the following code?

DECLARE
   num number;
   fn number;

FUNCTION fx(x number)
RETURN number 
IS
   f number;
BEGIN
   IF x=0 THEN
      f := 1;
   ELSE
      f := x * fx(x-1);
   END IF;
RETURN f;
END;

BEGIN
   num:= 5;
   fn := fx(num);
   dbms_output.put_line(fn);
END;

A - 1

B - 5

C - 10

D - 125

Answer : D

Q 6 - Consider the exception declared as −

emp_exception1 EXCEPTION;

Which of the following statement will correctly call the exception in a PL/SQL block?

A - IF c_id <= 0 THEN ex_invalid_id;

B - IF c_id <= 0 THEN CALL ex_invalid_id;

C - IF c_id <= 0 THEN RAISE ex_invalid_id;

D - IF c_id <= 0 THEN EXCEPTION ex_invalid_id;

Answer : C

plsql_questions_answers.htm
Advertisements