PL/SQL Online Quiz


Advertisements


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 - To get the server output result and display it into the screen, you need to write −

A - set serveroutput on

B - set server output on

C - set dbmsoutput on

D - set dbms output on

Answer : A

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' );
   ELSIF ( a = 75 )
      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

it has the THEN keyword missing in the ELSIF statement

Q 4 - Consider the following code snippet: how many times the loop will run?

DECLARE
   a number(2);
BEGIN
   FOR a in 10 .. 20 LOOP
       END LOOP;
END;

A - 11

B - 10

C - 9

D - Infinite loop.

Answer : A

Q 5 - Which of the following is a way of passing parameters to PL/SQL subprograms?

A - Positional notation

B - Named notation

C - Mixed notation

D - All of the above.

Answer : D

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 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 - Any subprogram not in the package specification but coded in the package body is called a

A - Public object.

B - Private object.

C - None of the above.

D - Both of the above.

Answer : B

Q 10 - What will be the output of the following code?

DECLARE
   lines dbms_output.chararr;
   num_lines number;
BEGIN
    dbms_output.enable;
   dbms_output.put_line('Hello!');
   dbms_output.put_line('Hope you are doing well!');
   num_lines := 2;
   dbms_output.get_lines(lines, num_lines);
 
   FOR i IN 1..num_lines LOOP
      dbms_output.put_line(lines(i));
   END LOOP;
END;

A - Hello!

     Hope you are doing well!

B - He

     Ho

C - Hello!

     Hope you

D - Hello!

Answer : A


plsql_questions_answers.htm

Advertisements