| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice Test
Share
easy Solved by 6 students
Java Loop Printing Output
< Prev
Next >

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(“*”);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251311 0m 00s 100
#2y.seong202711 0m 07s 93
#3kimtrinhqldacamle11 0m 29s 71
#4hitrishabhatia14 0m 00s 70
#5suhanakochhar00612 0m 51s 39
APFIVE © 2020.
Email: [email protected]|Privacy Policy