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 1 - Which of the following is not a PL/SQL unit?

A - Table

B - Type

C - Trigger

D - Package

Answer : A

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

DECLARE
   a number(3) := 100;
   b number(3) := 200;
BEGIN
   IF( a = 100 ) THEN
      IF( b <> 200 ) THEN
         dbms_output.put_line(b);
      END IF;
   END IF;
   dbms_output.put_line(a);
END;

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

B - 200

C - 200

     100

D - 100

Answer : D

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 - The following code tries to fetch some information from all the rows in a table named customers for use in a PL/SQL block. What is wrong in the following code?

DECLARE
   c_id customers.id%type;
   c_name customers.name%type;
   c_addr customers.address%type;
   CURSOR c_customers is
      SELECT id, name, address FROM customers;
BEGIN
   LOOP
      FETCH c_customers into c_id, c_name, c_addr;
      EXIT WHEN c_customers%notfound;
      dbms_output.put_line(c_id || ' ' || c_name || ' ' || c_addr);
   END LOOP;
   CLOSE c_customers;
END;

A - It need not use a cursor.

B - The cursor is not opened.

C - It will not print information from all the rows.

D - There is nothing wrong in the code.

Answer : B

plsql_questions_answers.htm
Advertisements