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.
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;
}
}
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.
hyodaeun
Highly Voted 5 years, 10 months agoMamlouk_Med
Highly Voted 5 years, 9 months agovic88
Most Recent 1 week, 5 days ago7df49fb
9 months agoarjunrawatirissoftware
1 year, 2 months agoDarGrin
1 year, 2 months agodsms
1 year, 4 months agoAnixtc
1 year, 7 months agoVicky_65
1 year, 8 months agowillokans
2 years agocarloswork
2 years agoacyuta
2 years, 6 months agobakhdak
2 years, 6 months agoarcher1903
2 years, 6 months agoarcher1903
2 years, 6 months agoDavid2606
2 years, 10 months agooca808reattempt
2 years, 11 months ago