exam questions

Exam 1z0-811 All Questions

View all questions & answers for the 1z0-811 exam

Exam 1z0-811 topic 1 question 7 discussion

Actual exam question from Oracle's 1z0-811
Question #: 7
Topic #: 1
[All 1z0-811 Questions]

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?

  • A. enhanced for
  • B. standard for
  • C. while
  • D. do-while
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
electri
4 weeks ago
Selected Answer: A
Only with A it's not possible to access the elements in the array in a special order of last to first. With standard for, while and do-while you can always access the array in the order you want. with enhanced for you only receive the element itself, you don't acces the array. To print the array in reverse order with an enhanced for loop, you would need to reverse the order of the array before you traverse it with the enhanced for loop.
upvoted 1 times
...
krysitian
3 months, 4 weeks ago
and again false answer given....
upvoted 1 times
...
tabrezshaikh13
12 months ago
Selected Answer: 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.
upvoted 3 times
...
CintiaMoon
1 year ago
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); }
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago