PLSQL Mock Test II
PLSQL Mock Test II
This section presents you various set of Mock Tests related to PL/SQL. You can download these
sample mock tests at your local machine and solve offline at your convenience. Every mock test is
supplied with a mock test key to let you verify the final score and grade yourself.
DECLARE
a number(3) := 100;
b number(3) := 200;
BEGIN
IF( a = 100 ) THEN
IF( b <> 200 ) THEN
dbms_output.put_line(b);
END IF;
END IF;
dbms_output.put_line(a);
END;
B - 200
C - 200
100
D - 100
A - In the basic loop structure, sequence of statements is enclosed between the LOOP and END
LOOP statements.
B - The WHILE loop repeats a statement or group of statements while a given condition is true.
C - The FOR loop executes a sequence of statements multiple times and abbreviates the code
that manages the loop variable.
D - The label name can also appear at the end of the LOOP statement or with an EXIT statement.
DECLARE
x number := 1;
BEGIN
LOOP
dbms_output.put_line(x);
x := x + 1;
IF x > 10 THEN
exit;
END IF;
dbms_output.put_line('After Exit x is: ' || x);
END;
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;
A-4
B-4
C-4
Q 6 - 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;
A - 10
B-8
C-7
D-9
Q 7 - Consider the following code snippet: how many times the loop will run?
DECLARE
a number(2);
BEGIN
FOR a in 10 .. 20 LOOP
END LOOP;
END;
A - 11
B - 10
C-9
D - Infinite loop.
DECLARE
a number(2) ;
BEGIN
FOR a IN REVERSE 10 .. 20 LOOP
END LOOP;
dbms_output.put_line(a);
END;
A - 11
B - 10
C - 29
D - 30
A - World
B - Hello
C - orld
Q 10 - Which of the following is not true about the PL/SQL data structure VARRAY?
Q 11 - Which of the following is the correct syntax for creating a VARRAY named
grades, which can hold 100 integers, in a PL/SQL block?
Q 12 - Which of the following is true about the PL/SQL data structure VARRAY?
B - A VARRAY type is created with the CREATE VARRAY statement, at the schema level.
C - Maximum size of a VARRAY can be changed using the ALTER TYPE statement.
D - Maximum size of a VARRAY can be changed using the ALTER VARRAY statement.
Q 13 - Which of the following is not true about the PL/SQL data structure VARRAY?
B - You can initialize the VARRAY elements using the constructor method of the VARRAY type,
which has the same name as the VARRAY.
A - At schema level.
B - Inside a package.
C - An IN OUT parameter passes an initial value to a subprogram and returns an updated value to
the caller.
DECLARE
a number;
b number;
c number;
BEGIN
a:= 2;
b:= 5;
findMin(a, b, c);
dbms_output.put_line(c);
END;
A-2
B-5
C-0
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;
A-5
B - 10
C - 25
D-0
A - Positional notation
B - Named notation
C - Mixed notation
C - The RETURN clause does not specify the data type of the return value.
D - The AS keyword is used instead of the IS keyword for creating a standalone function.
D - Nothing wrong.
DECLARE
a number;
b number;
c number;
FUNCTION fx(x IN number, y IN number)
RETURN number
IS
z number;
BEGIN
IF x > 2*y THEN
z:= x;
ELSE
z:= 2*y;
END IF;
RETURN z;
END;
BEGIN
a:= 23;
b:= 47;
c := fx(a, b);
dbms_output.put_line(c);
END;
A - 46
B - 47
C - 94
D - 23
DECLARE
num number;
fn number;
BEGIN
num:= 5;
fn := fx(num);
dbms_output.put_line(fn);
END;
A-1
B-5
C - 10
D - 125
C - The set of rows the cursor holds is referred to as the active set.
C - The most recent implicit cursor is called the SQL cursor, and has the attributes like %FOUND,
%ISOPEN, %NOTFOUND, and %ROWCOUNT.
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;
ANSWER SHEET
1 D
2 D
3 B
4 C
5 A
6 C
7 A
8 B
9 A
10 B
11 D
12 C
13 D
14 D
15 D
16 A
17 C
18 D
19 C
20 A
21 C
22 D
23 A
24 C
25 B
Loading [MathJax]/jax/output/HTML-CSS/jax.js