Java Loop Printing Output
Which code snippet should be inserted as the missing line to print an asterisk (*) followed by a new line on each iteration of the loop?
public class PrintStars {
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
// missing line
}
}
}
A
System.out.println(“*”);
B
printLine(“*”);
C
System.out.println(“*\n”);
D
System.out.print(“*”);
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #2 | y.seong2027 | 1 | 1 | 0m 07s | 93 |
| #3 | kimtrinhqldacamle | 1 | 1 | 0m 29s | 71 |
| #4 | hitrishabhatia | 1 | 4 | 0m 00s | 70 |
| #5 | suhanakochhar006 | 1 | 2 | 0m 51s | 39 |
APFIVE