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 - What would be printed when the following code is executed?

DECLARE
      x   NUMBER;
    BEGIN
      
       x := 5;
       x := 10;
       dbms_output.put_line(-x);
       dbms_output.put_line(+x);
       x := -10;
       dbms_output.put_line(-x);
       dbms_output.put_line(+x);
   END;

A - -10

     10

     10

     -10

B - 10

     -10

     10

     -10

C - -10

     +10

     +10

     -10

D - 10

     -10

     -10

     10

Answer : A

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

DECLARE
   grade char(1) := 'B';
BEGIN
   case 
      when grade = 'A' then dbms_output.put_line('Excellent');
      when grade = 'B' then dbms_output.put_line('Very good');
      when grade = 'C' then dbms_output.put_line('Well done');
      when grade = 'D' then dbms_output.put_line('You passed');
      when grade = 'F' then dbms_output.put_line('Better try again');
      else dbms_output.put_line('No such grade');
   end case;
END;

A - It has syntax error, so there will not be any output.

B - B

C - Very good

D - No such grade

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 - Observe the following code and fill in the blanks −

DECLARE 
   total_rows number(2);
BEGIN
   UPDATE employees
   SET salary = salary + 500;
   IF ____________ THEN
      dbms_output.put_line('no employees selected');
   ELSIF ___________ THEN
      total_rows := _____________;
      dbms_output.put_line( total_rows || ' employees selected ');
   END IF; 
END;

A - %notfound, %found, %rowcount.

B - sql%notfound, sql%found, sql%rowcount.

C - sql%found, sql%notfound, sql%rowcount.

D - %found, %notfound, %rowcount.

Answer : B

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;

The optional [FOR EACH ROW] clause specifies

A - A table with index.

B - A table with primary key.

C - A row level trigger.

D - A table with a unique key.

Answer : C

plsql_questions_answers.htm
Advertisements