- 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.
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 wont execute, it has syntax error
B - It will print num: 95 num: 195
Answer : B
Q 3 - Which of the following is not true about PL/SQL loop structures?
B - The WHILE loop repeats a statement or group of statements while a given condition is true.
Answer : D
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;
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;
Answer : D
Q 6 - Which of the following code will open a cursor named cur_employee?
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 optional [FOR EACH ROW] clause specifies
Answer : C
Q 8 - All objects placed in a package specification are called
Answer : A
Q 9 - Which of the following code is the correct syntax for creating an index-by table named salary that will store integer values along with names and the name field will be the key?
A - TYPE salary IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
B - CREATE TABLE salary OF NUMBER INDEX BY VARCHAR2(20);
C - TYPE salary IS INDEXED TABLE OF NUMBER INDEX BY VARCHAR2(20);
Answer : A
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.
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