| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy
While Loop Iteration Count
< Prev
Next >

How many iterations does the while-loop in whileLoopMethod() execute when invoked?

class BaseCounter {
    public void whileLoopMethod() {
        int count = 0;
        int i = 2;
        while (i < 10) {
            count++;
            i += 2;
        }
        System.out.println(count);
    }
}

class DerivedCounter extends BaseCounter { }

public class Main {
    public static void main(String[] args) {
        DerivedCounter dc = new DerivedCounter();
        dc.whileLoopMethod();
    }
}
A

3

B

5

C

6

D

4

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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