1Z0-149 practice question 11 of 15
SERVEROUTPUT is enabled. Which code block will display the values from 1 to 10 in descending order?
Full set: 65 questionsBoth code blocks will correctly display the values from 10 down to 1. Option B uses a FOR loop with the REVERSE keyword, which is the most concise and idiomatic PL/SQL construct for iterating backwards over a fixed integer range. Option D uses a WHILE loop, which also achieves the correct result by explicitly initializing a counter to 10, checking its value in each iteration, and decrementing it. Both are functionally correct and produce the required output.
A: The standard FOR i IN 1..10 loop iterates in ascending order, printing numbers from 1 to 10. C: A FOR loop with a range like 10..1 will not execute any iterations because the lower bound is greater than the upper bound.
1. Oracle Database PL/SQL Language Reference, 21c, Chapter 4, "PL/SQL Control Statements". Section: "FOR LOOP Statement". It states, "The REVERSE keyword causes the loop to be executed in reverse, from the upper bound to the lower bound."
2. Oracle Database PL/SQL Language Reference, 21c, Chapter 4, "PL/SQL Control Statements". Section: "WHILE LOOP Statement". This section describes the syntax and provides examples of using a WHILE loop with a counter, similar to the implementation in option D.
Keep practicing
Take the free 1Z0-149 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1Z0-149 practice questions
- Question 3Which two PL/SQL elements can be deprecated using the DEPRECATE pragma? (Choose two.)
- Question 5Which two statements are true about using the OR REPLACE clause when creating named subpr…
- Question 6Which three are true about functions and procedures? (Choose three.)
- Question 8Which two are true about the PLSQL_CODE_TYPE parameter? (Choose two.)
- Question 9Which three SQL statements, embedded in PL/SQL, typically benefit from using variables de…
- Question 15SERVEROUTPUT is enabled. Which is the correct method to use a PACKAGED CONSTANT in SELECT…
