![PL/SQL Tutorial](/plsql/images/plsql-mini-logo.jpg)
- PL/SQL Tutorial
- 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 Useful Resources
- PL/SQL - Questions and Answers
- PL/SQL - Quick Guide
- PL/SQL - Useful Resources
- PL/SQL - Discussion
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](/images/questions_and_answers.png)
Q 1 - Which of the following is true about the execution section of a PL/SQL block?
A - It is enclosed between the keywords BEGIN and END.
B - It is a mandatory section.
Answer : D
Q 2 - What is wrong in the following code?
DECLARE c_id := 1; c_name customers.name%type; c_addr customers.address%type; BEGIN SELECT name, address INTO c_name, c_addr FROM customers WHERE id = c_id; END;
A - You cannot use the SELECT INTO statement of SQL to assign values to PL/SQL variables.
B - The SELECT INTO statement here is wrong. It should be: SELECT c_name, c_address INTO name, addr
C - The WHERE statement is wrong. It should be: WHERE id := c_id;
D - The variable c_id should be declared as a type-compatible variable as −
c_id customers.id%type := 1;
Answer : D
Q 3 - Which of the following is not true about labelling PL/SQL loops?
A - PL/SQL loops can be labelled.
B - The label should be enclosed by angle brackets (< and >).
C - The label name appears at the beginning of the LOOP statement.
D - The label name can also appear at the end of the LOOP statement or with an EXIT statement.
Answer : B
Explanation
The label should be enclosed by double angle brackets (<< and >>)
Q 4 - Which of the following is not true about the PL/SQL data structure VARRAY?
A - It is a fixed-size sequential collection of elements.
B - The elements can of various data types.
C - It is used to store an ordered collection of data.
D - Each element in a VARRAY has an index associated with it.
Answer : B
Q 5 - Which of the following is not true about PL/SQL cursors?
A - A cursor is a view on a table.
B - A cursor holds the rows (one or more) returned by a SQL statement.
C - The set of rows the cursor holds is referred to as the active set.
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 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;
Which of the following holds true for the WHEN clause?
Answer : A
Q 8 - Which of the following statement will create the specification for a package named cust_sal
A -
CREATE PACKAGE BODY cust_sal AS
PROCEDURE find_sal(c_id customers.id%type);
END cust_sal;
B -
CREATE PACKAGE cust_sal AS
PROCEDURE find_sal(c_id customers.id%type);
END cust_sal;
D -
PACKAGE cust_sal AS
PROCEDURE find_sal(c_id customers.id%type);
END cust_sal;
Answer : B
Q 9 - Which of the following is not true about database transactions?
A - A database transaction is an atomic unit of work.
B - It may consist of one or more related SQL statements.
C - A successfully executed SQL statement and a committed transaction are not same.
Answer : D
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