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?
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?
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.
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.
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); }
and again false answer given....