- PL/SQL - Home
- PL/SQL - Overview
- PL/SQL - Environment
- PL/SQL - Basic Syntax
- PL/SQL - Data Types
- PL/SQL - Variables
- PL/SQL - Constants and Literals
- PL/SQL - Operators
- PL/SQL - Conditions
- PL/SQL - Loops
- PL/SQL - Strings
- PL/SQL - Arrays
- PL/SQL - Procedures
- PL/SQL - Functions
- PL/SQL - Cursors
- PL/SQL - Records
- PL/SQL - Exceptions
- PL/SQL - Triggers
- PL/SQL - Packages
- PL/SQL - Collections
- PL/SQL - Transactions
- PL/SQL - Date & Time
- PL/SQL - DBMS Output
- PL/SQL - Object Oriented
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.
Q 1 - Which of the following is not true about the declaration section of a PL/SQL block?
A - This section starts with the DECLARE keyword.
B - It is a mandatory section.
C - It defines all variables, cursors, subprograms, and other elements to be used in the program.
Answer : B
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;
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' );
ELSIF ( a = 75 )
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;
B - It will print 'None of the values is matching'.
None of the values is matching
Exact value of a is: 100
Answer : A
Explanation
it has the THEN keyword missing in the ELSIF statement
Q 4 - Consider the following code snippet: how many times the loop will run?
DECLARE
a number(2) := 9;
BEGIN
WHILE a < 30 LOOP
a := a + 3;
END LOOP;
END;
Answer : C
Q 5 - What will be printed by the following PL/SQL block?
DECLARE a number; PROCEDURE squareNum(x IN OUT number) IS BEGIN x := x * x; END; BEGIN a:= 5; squareNum(a); dbms_output.put_line(a); END;
Answer : C
Q 6 - Which of the following code correctly create a record named book with two field title and author?
A - TYPE book IS RECORD
(title varchar(50),
author varchar(50),
);
B - RECORD book
(title varchar(50),
author varchar(50),
);
C - CREATE RECORD book
(title varchar(50),
author varchar(50),
);
D - CREATE TYPE book
(title varchar(50),
author varchar(50),
);
Answer : A
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
Answer : B
Q 8 - Which of the following is true about PL/SQL index-by tables?
A - It is a set of key-value pairs.
B - Each key is unique and is used to locate the corresponding value.
Answer : D
Q 9 - Which of the following is not true about PL/SQL nested tables?
B - A nested table can be stored in a database column.
C - Elements of a nested table could be a %ROWTYPE of any database table.
D - Elements of a nested table could also be %TYPE of any database table field.
Answer : A
Q 10 - Which of the following is not true about the Constructors?
A - These are functions that return a new object as its value.
B - Every object has a system defined constructor method.