Skip to main content

Oracle Database Programming MCQs with Answers

Practice important Oracle Database Programming MCQs with answers and explanations.

Chapter: 9
Q141:
What will the following code calculate: `FOR i IN 1..10 LOOP IF MOD(i,2) = 0 THEN dbms_output.put_line('Even'); END IF;`?
A. Odd values
B. Even values
C. All numbers from 1 to 10
D. No output
Correct Answer: B
Chapter: 9
Q142:
Which PL/SQL loop guarantees at least one iteration regardless of the condition?
A. FOR loop
B. WHILE loop
C. DO-WHILE loop
D. CASE loop
Correct Answer: C
Chapter: 9
Q143:
How is a DO-WHILE loop implemented in PL/SQL?
A. Using FOR loop
B. Using WHILE loop
C. Using CASE statement
D. Using a simple loop with an exit condition
Correct Answer: D
Chapter: 9
Q144:
What is the error in the following code: `FOR i IN 1..10 LOOP i := i + 1; END LOOP;`?
A. Syntax error
B. Loop never executes
C. Incrementing the loop counter is not allowed
D. Loop terminates prematurely
Correct Answer: C
Chapter: 9
Q145:
What is the output of the following program: `FOR i IN 1..10 LOOP dbms_output.put_line('Value of i: ' || i); END LOOP;`?
A. Error
B. Loop terminates early
C. Value of i from 1 to 10 is printed
D. Nothing is printed
Correct Answer: C
Chapter: 9
Q146:
Which of the following is true for a REVERSE FOR loop in PL/SQL?
A. Iteration proceeds upwards
B. Iteration proceeds downwards
C. Exit condition is checked first
D. Loop never executes
Correct Answer: B
Chapter: 9
Q147:
What will happen if the start value is greater than the end value in a FOR loop?
A. Loop will execute normally
B. Loop will never start
C. Program crashes
D. Error in syntax
Correct Answer: B
Chapter: 10
Q148:
What does the 'CONTINUE' statement do in a loop?
A. Skips the current iteration
B. Exits the loop completely
C. Pauses the loop
D. Starts a new loop iteration
Correct Answer: A
Chapter: 10
Q149:
In the given code, what does 'CONTINUE' do when 'x < 3'?
A. Skips the remaining code and continues to the next iteration
B. Exits the loop immediately
C. Pauses the loop for a moment
D. Does nothing
Correct Answer: A
Chapter: 10
Q150:
What is the output of the 'CONTINUE' statement with 'x < 3' in the provided example?
A. Skips code after 'CONTINUE' and continues to the next iteration
B. Terminates the loop completely
C. Outputs 'x' value before the 'CONTINUE' statement
D. Restarts the loop from the beginning
Correct Answer: A
Chapter: 10
Q151:
How many times will the inner loop execute in the provided nested loop example?
A. 4 times
B. 2 times
C. 10 times
D. 1 time
Correct Answer: A
Chapter: 10
Q152:
What will be the output of the following code segment? 'DBMS_OUTPUT.PUT_LINE('Inner Loop counter is ' || v_innerloopcounter);'
A. Inner Loop counter is 1 to 4
B. Inner Loop counter is 1 to 10
C. Inner Loop counter is 1 to 2
D. No output
Correct Answer: A
Chapter: 10
Q153:
The 'CONTINUE WHEN' statement is used to:
A. Skip the rest of the current iteration and continue with the next iteration
B. Exit the loop immediately
C. Wait for a condition to be met
D. Restart the loop
Correct Answer: B
Chapter: 10
Q154:
In a nested loop, which loop executes first?
A. The inner loop
B. The outer loop
C. Neither loop
D. Both loops simultaneously
Correct Answer: A
Chapter: 10
Q155:
How does a 'WHILE' loop differ from a 'FOR' loop in terms of execution?
A. A 'WHILE' loop runs until a condition is false; a 'FOR' loop runs a set number of times
B. A 'WHILE' loop always executes first; a 'FOR' loop executes after initialization
C. A 'FOR' loop runs indefinitely; a 'WHILE' loop runs a set number of times
D. A 'WHILE' loop is faster; a 'FOR' loop is slower
Correct Answer: A
Chapter: 10
Q156:
Fill in the blank: The 'CONTINUE' statement causes the loop to ________ and continue with the next iteration.
A. skip remaining code in the current iteration
B. exit immediately
C. wait for a condition to be met
D. restart the loop
Correct Answer: A
Chapter: 10
Q157:
Fill in the blank: In a nested loop, if the outer loop has 2 iterations and the inner loop has 4 iterations, the inner loop will execute a total of ________ times.
A. 8 times
B. 2 times
C. 4 times
D. 6 times
Correct Answer: A
Chapter: 10
Q158:
What is the role of 'EXIT WHEN' in the provided loop example?
A. To terminate the loop when a specified condition is met
B. To continue to the next iteration
C. To restart the loop from the beginning
D. To skip the current iteration
Correct Answer: A
Chapter: 11
Q159:
What does a cursor in Oracle do?
A. Handles single rows
B. Manages multiple rows
C. Executes SQL statements
D. Defines table structures
Correct Answer: B
Chapter: 11
Q160:
Which type of cursor is created automatically by Oracle?
A. Explicit
B. Implicit
C. Dynamic
D. Static
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Oracle Database Programming

🚀 Start Quiz Now