exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 20 discussion

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

Given the code fragment:

Which modification enables the code to print 54321?

  • A. Replace line 6 with System.out. print (--x) ;
  • B. At line 7, insert x --;
  • C. Replace line 6 with --x; and, at line 7, insert System.out.print (x);
  • D. Replace line 12 with return (x > 0) ? false: true;
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
hyodaeun
Highly Voted 5 years, 10 months ago
Answer is B
upvoted 27 times
...
Mamlouk_Med
Highly Voted 5 years, 9 months ago
answer is B, Sur la ligne 12 du programme, l'utilisation de "x--" dans la méthode isAvailable n'affecte pas la variable x de la méthode principale, car Java est toujours "pass by value". L'option A fera la sortie "43210". Option B, vous pouvez générer avec succès "54321". Option C, cette logique est la même que l'option A. L'option D, tant que la boucle ne sera pas exécutée.
upvoted 11 times
...
vic88
Most Recent 1 week, 5 days ago
Selected Answer: B
x-- at line 7
upvoted 1 times
...
7df49fb
9 months ago
B changes made to x inside the isAvailable method do not affect the x in the main method because Java passes arguments by value.
upvoted 2 times
...
arjunrawatirissoftware
1 year, 2 months ago
Answer - B
upvoted 1 times
...
DarGrin
1 year, 2 months ago
Selected Answer: B
B is only one correct answer
upvoted 1 times
...
dsms
1 year, 4 months ago
Selected Answer: B
Correct answer is B
upvoted 1 times
...
Anixtc
1 year, 7 months ago
This is majorly helpful
upvoted 1 times
...
Vicky_65
1 year, 8 months ago
Selected Answer: B
option is B
upvoted 1 times
...
willokans
2 years ago
Answer is B x-- will allow the loop to iterate from 5 to1 until x !> 0
upvoted 1 times
...
carloswork
2 years ago
Selected Answer: B
Answer is B. To test: public class Test { public static void main(String[] args) { int x = 5; while(isAvailable(x)) { System.out.print(x); x--; // Answer B - Its ok. } } public static boolean isAvailable (int x) { return x-- > 0 ? true : false; } }
upvoted 1 times
...
acyuta
2 years, 6 months ago
Selected Answer: B
B is correct. It will be in sync with what is happening inside the function isAvailable
upvoted 1 times
...
bakhdak
2 years, 6 months ago
Selected Answer: B
Answer is B
upvoted 1 times
...
archer1903
2 years, 6 months ago
Selected Answer: B
Answer is B
upvoted 1 times
...
archer1903
2 years, 6 months ago
Selected Answer: B
Answer is B
upvoted 1 times
...
David2606
2 years, 10 months ago
Selected Answer: B
answer is B, la respuesta correcta es B
upvoted 1 times
...
oca808reattempt
2 years, 11 months ago
Selected Answer: B
Ans is B
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