exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 130 discussion

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

Given the code fragment:

Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of the array in reverse order? (Choose two.)
A.

B.

C.

D.

E.

Show Suggested Answer Hide Answer
Suggested Answer: AE

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
MPignaProTech
2 months, 4 weeks ago
AE are correct
upvoted 1 times
...
akbiyik
2 years, 1 month ago
Answer is AE
upvoted 1 times
...
carloswork
2 years, 1 month ago
Answer is AE. To test: public static void main(String[] args) { int array[] = {10, 20, 30, 40, 50}; int x = array.length; // Answer A - Ok /* while (x>0) { x--; System.out.println(array[x]); } */ // Answer B - ArrayIndexOutOfBoundsException // x = -1 /* do { x--; System.out.print(array[x]); } while (x >= 0); */ // Answer C - ArrayIndexOutOfBoundsException // x = 5 /* while (x >= 0) { System.out.print(array[x]); x--; } */ // Answer D - ArrayIndexOutOfBoundsException // x = 5 /* do { System.out.print(array[x]); --x; } while (x > 0); */ // Answer E - Ok /* while(x > 0) { System.out.println(array[--x]); } */ }
upvoted 1 times
...
iSnover
2 years, 3 months ago
The correct answer is AE. Remember that when we are going to make a reverse index we must put ">= 0", because if we put "=0" it will return an exception.
upvoted 1 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