While Loop Iteration Count
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
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE