Exam 1z0-811 All QuestionsBrowse all questions from this exam
Question 7

You have been asked to develop a Java program that prints the elements of an array in reverse order.

Which looping statement cannot be used to meet the requirement?

    Correct Answer: A

    The enhanced for loop cannot be used to traverse an array in reverse order. This type of loop is designed to iterate over elements from the beginning to the end, providing no means to control the iteration direction. On the other hand, standard for, while, and do-while loops offer the flexibility to control the index variable, making it possible to iterate through the array in reverse order.

Discussion
tabrezshaikh13Option: A

A is the correct answer. Enhanced for loop cannot be used for traverse an array in reverse order. Rest all loops can be used. Check on internet for solutions to traverse array in reverse order using Standard For, While and Do-While Loops.

CintiaMoonOption: A

Answer D is incorrect. You can use Do-while to print an array in reverse order. Example: public static void main(String[] args) { int[] array = {1, 2, 3, 4, 5}; int index = array.length - 1; do { System.out.println(array[index]); index--; } while (index >= 0); }

krysitian

and again false answer given....