Oracle 1Z0-808 Exam question no. 76

Q.– Given the code fragment:- 

3. public static void main(String[] args) { 
4.      int x = 6: 
5.      while (isAvailable(x)) { 
6.              System.out.print (x); 
7. 
8.       } 
9. } 
10.
11. public static boolean isAvailable(int x) { 
12.            return --x > 0 ? true : false; 
13. } 

Which modification enables the code to print 54321? 

A) Replace line 12 with return (x > 0) ? false : true; 

B) At line 7, insert x--; 

C) Replace line 6 with System.out.print(--x) ; 

D) Replace line 5 with while(isAvailable(--x))  {


⧪ please give your answer in a comment section.

Post a Comment

5 Comments