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 2 - What will be the output of the following code snippet?

DECLARE
   a number (2) := 21;
   b number (2) := 10;
BEGIN
   
   IF ( a <= b ) THEN
      dbms_output.put_line(a);
   END IF;

   IF ( b >= a ) THEN
      dbms_output.put_line(a);
   END IF;
   
   IF ( a <> b ) THEN
      dbms_output.put_line(b);
   
   END IF;

END;

A - 2

B - 21

C - 10

D - 21, 10

Answer : C

Q 3 - What is wrong in the following code snippet?

DECLARE
   x number := 1;
BEGIN
   LOOP
      dbms_output.put_line(x);
      x := x + 1;
      IF x > 10 THEN
         exit;
      END IF;
     dbms_output.put_line('After Exit x is: ' || x);
END;

A - There is nothing wrong.

B - The IF statement is not required.

C - There should be an END LOOP statement.

D - The exit statement should be in capital letters.

Answer : C

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

Q 7 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

Which of the following holds true for the [REFERENCING OLD AS o NEW AS n] clause?

A - This allows you to refer new and old values for various DML statements, like INSERT, UPDATE, and DELETE.

B - OLD and NEW references are not available for table level triggers.

C - You can use them for record level triggers.

D - All of the above.

Answer : D

Q 8 - All objects placed in a package specification are called

A - Public objects.

B - Private objects.

C - None of the above.

D - Both of the above.

Answer : A

Answer : B

Explanation

The Map method is a function implemented in such a way that its value depends upon the value of the attributes.

plsql_questions_answers.htm
Advertisements