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

DECLARE
   a number (2) := 21;
   b number (2) := 10;
BEGIN
   
   IF ( a <= b ) THEN
      dbms_output.put_line(a);
   END IF;

   IF ( b >= a ) THEN
      dbms_output.put_line(a);
   END IF;
   
   IF ( a <> b ) THEN
      dbms_output.put_line(b);
   
   END IF;

END;

A - 2

B - 21

C - 10

D - 21, 10

Answer : C

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

DECLARE
   x number := 4;
BEGIN
   LOOP
      dbms_output.put_line(x);
      x := x + 1;
      exit WHEN x > 5;
   END LOOP;
      dbms_output.put_line(x);
END;

A - 4

     5

     6

B - 4

     5

C - 4

D - None of the above.

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 6 - Which of the following code will successfully declare an exception named emp_exception1 in a PL/SQL block?

A - EXCEPTION emp_exception1;

B - emp_exception1 EXCEPTION;

C - CREATE EXCEPTION emp_exception1;

D - CREATE emp_exception1 AS EXCEPTION;

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

Q 10 - The following code tries to create a base object named rectangle, which will be inherited. What is wrong in the code?

CREATE OR REPLACE TYPE rectangle AS OBJECT
(length number,
 width number,
 member function enlarge( inc number) return rectangle,
 NOT FINAL member procedure display) 

A - The declaration should read as CREATE OR REPLACE OBJECT rectangle AS …

B - The base object should not have any member attribute or functions.

C - The base object rectangle should be declared as NOT FINAL.

D - None of the above

Answer : C

Explanation

The corrected code is −

CREATE OR REPLACE TYPE rectangle AS OBJECT
(length number,
 width number,
 member function enlarge( inc number) return rectangle,
 NOT FINAL member procedure display) NOT FINAL

plsql_questions_answers.htm

Advertisements