Given the code fragment: Which modification enables the code to print 54321?
A.
Replace line 12 With return (x > 0) ? false: true;
B.
Replace line 6 with –x; and, at line 7, insert system, out. print (x);
C.
Replace line 6 with System, out. print (–x) ;
D.
At line 1, insert x –;
Didn’t have success with any of the above answers.
Works changing the line 6 to
System.out.println(x–);
I guess tha there are a problem with the ocr and the answers that say
D.
At line 1, insert x –;
mean…
D.
At line 7, insert x –;
at line 7 insert: x–;
At line 7 insert x– ;
Is the only correct answer so I think that is what Option D is supposed to be. These are definitely fake dumps because the options are not even given correctly.
I doubt Oracle would make so many stupid mistakes in a single test 🙂
For option D, the line 7 should be insert x-;
Non of these. (answer is Replace line 6 with System.out.print (x–) 😉
That option is not up there. Option C is “Replace line 6 with System.out.println(-x)”,which prints 43210.
So the only option is D, assuming that it means, Insert x– at line 7;.
x-; isn’t even a statement. It should be at least x–; (two minus signs).
A lot of bad mistakes in this dump.
Ah, i see, there is bug in this webpage itself, it shosw two minus signs as a long dash. XD
none of the given options are correct;
A, B, and C lead to infinite loop. while D will generate compilation error.
the right answer is to replace line 6 with System.out.print(x–);
it seems that questions and answers are incorrect on this site!
Which modification enables the code to print 54321?
A. Replace line 12 With return (x > 0) ? false: true;
B. Replace line 6 with –x; and, at line 7, insert system, out. print (x);
C. Replace line 6 with System, out. print (–x) ;
D. At line 7, insert x –;
Answer: D
????
option D description is wrong,
it should be “At line 7, insert x–;”
Correct answer is D.
All the options mentioned is incorrect. changing line 6 to this System.out.print(x–); shall give the desired output “54321”
D.
I think the following is correct – instead of “At line 1 – use at line 7”
At line 1, insert x –;