zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank
GlossaryGlossary

Iteration in Programming

Question 1
college-boardComputer Science AAPExam Style
1 mark

Which method would you use to determine the number of elements in an ArrayList named 'myList'?

Question 2
college-boardComputer Science AAPExam Style
1 mark

If you need to ensure that an instance of your 'House' class always has an 'Address', what technique would best enforce this relationship without inheriting from 'Address'?

Question 3
college-boardComputer Science AAPExam Style
1 mark

What happens to the value of "i" after each iteration in a standard for loop structure such as for(int i = 0; i < 10; i++)?

Question 4
college-boardComputer Science AAPExam Style
1 mark

Given this code segment:

java  
int result =0;
for (int j=10; j>0;j--){
    if(j%3==0){
        result+=j;
    }
}

Which change will make result hold double its original final value after execution?

Question 5
college-boardComputer Science AAPExam Style
1 mark

What type of loop should you use when you need to repeat an action a fixed number of times?

Question 6
college-boardComputer Science AAPExam Style
1 mark

When would you choose a while loop over a for loop?

Question 7
college-boardComputer Science AAPExam Style
1 mark

What is the time complexity of a nested for loop where the outer loop runs n times and the inner loop runs n/2 times?

Feedback stars icon

How are we doing?

Give us your feedback and let us know how we can improve

Question 8
college-boardComputer Science AAPExam Style
1 mark

In Java, which of these data types can store decimal numbers?

Question 9
college-boardComputer Science AAPExam Style
1 mark

What will the following code output:

for (int i = 0; i < 5; i++) { System.out.print(i + " "); }

Question 10
college-boardComputer Science AAPExam Style
1 mark

In a decrementing for-loop structured as

java 
for(int x=n;x>0;x--){
//body //
}```
Which modification ensures that exactly half the numbers from N down to zero are processed?