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 - Consider the following code −

DECLARE
   -- Global variables 
   num number := 95; 
BEGIN 
   dbms_output.put_line('num: ' || num1);
   DECLARE 
      -- Local variables
      num number := 195; 
     BEGIN 
      dbms_output.put_line('num: ' || num1);
     END; 
END;

What will happen when the code is executed?

A - It won’t execute, it has syntax error

B - It will print

     num: 95

     num: 195

C - It will print

     num: 95

     num: 95

D - It will print

     num: 195

     num: 195

Answer : B

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 the following code snippet: what will be the output?

DECLARE
   a number(2) ;
BEGIN
   FOR a IN REVERSE 10 .. 20 LOOP
   END LOOP;
dbms_output.put_line(a);
END;

A - 11

B - 10

C - 29

D - 30

Answer : B

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 6 - Which of the following is not among the types of PL/SQL records?

A - Table-based

B - View-based

C - Cursor-based records

D - User-defined records

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 {INSERT [OR] | UPDATE [OR] | DELETE} clause specifies a

A - DDL operation.

B - DML operation.

C - None of the above.

D - Both of the above.

Answer : B


plsql_questions_answers.htm

Advertisements