- 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.
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 - What is the output of the following code?
DECLARE x number := 4; BEGIN LOOP dbms_output.put_line(x); x := x + 1; exit WHEN x > 5; END LOOP; dbms_output.put_line(x); END;
Answer : A
Q 4 - Which of the following is not true about the PL/SQL data structure VARRAY?
A - In oracle environment, the starting index for VARRAYs is always 1.
Answer : D
Q 5 - Observe the following code and fill in the blanks −
DECLARE total_rows number(2); BEGIN UPDATE employees SET salary = salary + 500; IF ____________ THEN dbms_output.put_line('no employees selected'); ELSIF ___________ THEN total_rows := _____________; dbms_output.put_line( total_rows || ' employees selected '); END IF; END;
A - %notfound, %found, %rowcount.
B - sql%notfound, sql%found, sql%rowcount.
Answer : B
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 true for querying a table in the same trigger?
Answer : A
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 - The collection method LIMIT
A - Returns the last (largest) index numbers in a collection that uses integer subscripts.
B - Returns the number of elements that a collection currently contains.
Answer : C
Q 10 - Which of the following code will create an object type named local_address with two field house_no and street?
A -
CREATE OR REPLACE OBJECT local_address
(house_no varchar2(10),
street varchar2(30),
);
B -
CREATE OR REPLACE TYPE local_address AS OBJECT
(house_no varchar2(10),
street varchar2(30),
);
C -
CREATE OR REPLACE OBJECT local_address AS
(house_no varchar2(10),
street varchar2(30),
);
D -
CREATE OR REPLACE CLASS local_address
(house_no varchar2(10),
street varchar2(30),
);
To Continue Learning Please Login
Login with Google