| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 10 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

printLine(“*”);

B

System.out.println(“*”);

C

System.out.print(“*”);

D

System.out.println(“*\n”);

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251311 0m 00s 100
#2y.seong202711 0m 07s 93
#3Pelisx11 0m 19s 81
#4kimtrinhqldacamle11 0m 29s 71
#5hitrishabhatia14 0m 00s 70
#6suhanakochhar00612 0m 51s 39
#7midnightasdark11 1m 07s 33
#8bommasam00012 18m 50s -1,040
Items per page:
10
1 – 8 of 8
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy