Programming loopss Flashcards

(15 cards)

1
Q

What are the three main types of loops?

A
  • For loop
  • While loop
  • do while loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 2 types of loop situations?

A
  • Indeterminate

- Determinate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an Indeterminate loop situation?

A
  • A situation where we don’t know in advance how many times we may have to repeat or iterate a loop body code.
  • Usually a while or do while loop is used in this scenario
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a determinate loop situation?

A
  • We know ahead of time exactly how many iterations our loop body code has to do.
  • Usually a for or a counter controlled loop is used in this scenario
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens in a while loop?

A
  • The loop continuation condition is checked (The brackets next to the while loop) before trying to run the loop body statement.
  • You need to include some information in the loop body that will eventually cause the condition to be false so that we can exit the loop.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a do- while loop?

A
  • A do while loop will always run at least once before the condition is checked
  • Often used as a data validation loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between break and continue?

A
  • The continue keyword will stop the current iteration of the loop whereas break will exit the loop completely
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the steps in creating a for loop?

A
  1. ) Set initial conditions for the loop and create the loop control variable
  2. ) Specify the conditions for the loop to continue. The brackets next to it aka the LCC
  3. ) Arrange it so that the loop control variable is incremented after each iteration of the loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an array?

A
  • A names set of contiguous memory cells

- Can be used to store both primitive and object data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What indexing do arrays use?

A
  • Arrays use zero based indexing. The first value in the array always starts at zero
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can data types be mixed in the elements of an array?

A
  • No
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The operator used in creating the array is the square brackets []. What is another name for this?

A
  • Array Index Operator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an array classified as in java

A
  • Arrays are objects in Java
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Instantiation gives values to the array. Once created can the array size change?

A
  • Array size is fixed and cant be changed once created
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Arrays are Homogeneous. What does this mean?

A
  • Means they can only store one type of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly