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 3 - Which of the following is true about the following code snippet?

DECLARE
   a number(3) := 100;
BEGIN
   IF (a = 50 ) THEN
      dbms_output.put_line('Value of a is 10' );
   ELSEIF ( a = 75 ) THEN
      dbms_output.put_line('Value of a is 20' );
   ELSE
       dbms_output.put_line('None of the values is matching');
   END IF;
   dbms_output.put_line('Exact value of a is: '|| a ); 
END;

A - It has syntax error.

B - It will print 'None of the values is matching'.

C - It will print

None of the values is matching

Exact value of a is: 100

D - None of the above.

Answer : A

Explanation

the ELSIF statement is wrongly written as ELSEIF

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 will be printed by the following PL/SQL block?

DECLARE
   a number;
   b number;
   c number;

PROCEDURE findMin(x IN number, y IN number, z OUT number) IS
BEGIN
   IF x < y THEN
      z:= x;
   ELSE
      z:= y;
   END IF;
END; 

BEGIN
   a:= 2;
   b:= 5;
   findMin(a, b, c);
   dbms_output.put_line(c);
END;

A - 2

B - 5

C - 0

D - Won’t print anything

Answer : A

Q 6 - Which of the following code will open a cursor named cur_employee?

A - OPEN cur_employee;

B - OPEN CURSOR cur_employee;

C - FETCH cur_employee;

D - FETCH CURSOR cur_employee;

Answer : A

Q 10 - The following code tries to create a base object named rectangle, which will be inherited. What is wrong in the code?

CREATE OR REPLACE TYPE rectangle AS OBJECT
(length number,
 width number,
 member function enlarge( inc number) return rectangle,
 NOT FINAL member procedure display) 

A - The declaration should read as CREATE OR REPLACE OBJECT rectangle AS …

B - The base object should not have any member attribute or functions.

C - The base object rectangle should be declared as NOT FINAL.

D - None of the above

Answer : C

Explanation

The corrected code is −

CREATE OR REPLACE TYPE rectangle AS OBJECT
(length number,
 width number,
 member function enlarge( inc number) return rectangle,
 NOT FINAL member procedure display) NOT FINAL
plsql_questions_answers.htm
Advertisements