- 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 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 PL/SQL decision making structures?
B - The IF statement also adds the keyword ELSE followed by an alternative sequence of statement.
C - The IF-THEN-ELSIF statement allows you to choose between several alternatives.
Answer : D
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 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 - The following code tries to fetch some information from all the rows in a table named customers for use in a PL/SQL block. What is wrong in the following code?
DECLARE
c_id customers.id%type;
c_name customers.name%type;
c_addr customers.address%type;
CURSOR c_customers is
SELECT id, name, address FROM customers;
BEGIN
LOOP
FETCH c_customers into c_id, c_name, c_addr;
EXIT WHEN c_customers%notfound;
dbms_output.put_line(c_id || ' ' || c_name || ' ' || c_addr);
END LOOP;
CLOSE c_customers;
END;
Answer : B
Q 7 - Which of the following is not a benefit of a database trigger?
A - Enforcing referential integrity
B - Event logging and storing information on table access
Answer : C
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 true about PL/SQL nested tables?
A - Nested tables are like one-dimensional arrays with arbitrary number of elements.
Answer : D
Q 10 - Which of the following is not true about the comparison methods?
A - These are used for comparing objects.
C - The Order methods implement some internal logic for comparing two objects.
Answer : B
Explanation
The Map method is a function implemented in such a way that its value depends upon the value of the attributes.