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

A - Table

B - Type

C - Trigger

D - Package

Answer : A

Q 2 - What value will be assigned to the variable declared as below −

counter binary_integer;

A - 0

B - 1

C - NULL

D - None of the above.

Answer : C

Q 3 - Which of the following is true about the following code snippet?

DECLARE
   a number(3) := 100;
BEGIN
   IF (a = 50 ) THEN
      dbms_output.put_line('Value of a is 10' );
   ELSEIF ( a = 75 ) THEN
      dbms_output.put_line('Value of a is 20' );
   ELSE
       dbms_output.put_line('None of the values is matching');
   END IF;
   dbms_output.put_line('Exact value of a is: '|| a ); 
END;

A - It has syntax error.

B - It will print 'None of the values is matching'.

C - It will print

None of the values is matching

Exact value of a is: 100

D - None of the above.

Answer : A

Explanation

the ELSIF statement is wrongly written as ELSEIF

Q 4 - Which of the following is the correct syntax for creating a VARRAY named grades, which can hold 100 integers, in a PL/SQL block?

A - TYPE grades IS VARRAY(100) OF INTEGERS;

B - VARRAY grades IS VARRAY(100) OF INTEGER;

C - TYPE grades VARRAY(100) OF INTEGER;

D - TYPE grades IS VARRAY(100) OF INTEGER;

Answer : D

Q 5 - What would be the output of the following code?

DECLARE
   num number;
   fn number;

FUNCTION fx(x number)
RETURN number 
IS
   f number;
BEGIN
   IF x=0 THEN
      f := 1;
   ELSE
      f := x * fx(x-1);
   END IF;
RETURN f;
END;

BEGIN
   num:= 5;
   fn := fx(num);
   dbms_output.put_line(fn);
END;

A - 1

B - 5

C - 10

D - 125

Answer : D

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