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 - 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

Answer : B

Explanation

The label should be enclosed by double angle brackets (<< and >>)

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

Answer : A

Explanation

A cursor is a memory area, known as context area, for processing an SQL statement, which contains all information needed for processing the statement.

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

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