Java Levels 3-4 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

loops

A

allow a chunk of code to be repeated over & over, depending on a condition

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

while

A

int x;

x = 0;

while(x < 10) { condition

System.out.println("Hello World!");

x++;

}

will repeat everything inside the curly braces of the loop as long as the condition inside the parentheses is true

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

x++

A

short for x = x + 1

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

incrementing

A

adding 1 to the value stored in the variable

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

increment operator

A

++ in x++

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

for

A

almost identical to while, but syntax diff

public class TheCount
 {
     public static void main()
     {
         for(int count = 1; count \<= 100; count++) {
             System.out.println(count + "! A-HA-HA!");
         }
     }
 }

for(initialization; condition; statement)

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

initiliazition

A

The initialization section of a for loop is done only one time before the loop starts. Most programmers use this section to declare their counting variable and set up its starting value.

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

counting variable/count

A

integer

set to a starting #

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

sentinel loop

A

waits for a condition to be true before stopping but doesn’t involve a looping variable

waiting for user to type something before it exits

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