Selection Control Structure Flashcards

1
Q

3 types of control structures

A

Sequential
Decisions/selection
Iteration

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

Sequential structure

A

Statements are executed in the order in which written

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

Decision structure

A

Changes flow or execution according to a condition

If, if-else, switch

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

Iteration structure

A

Repeat execution of a set of statements

I.e for and While loops

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

If, if else

A

If(condition) {

  Statements 

}

If(condition) {

  Statements } Else {

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

If - else if

A

If (condition1){

    Statements;

} else if (condition2){

    Statements;

} else if (condition 3){

    Statements  } else {

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

Nested if statements

A

Just meet credentials of first If to then consider second set

If (cond1) {

  If (cond2) {

       Statements;
 } else {

}}

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

Switch statements

A

Enables selection from a set of options. Switchable according to a value

Switch (expression or variable) {

     Case value1: statements;
                            Break;
     Case value2: statements;
                            Break;
      Default: statements;

}

If variable = value1 runs case, if not checks case 2 and if not then does default

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

What does switch work for?

A

Char, integral are supported, string is supported after Java 7.

FLOATS AND DOUBLES DONT WORK!

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

Do all conditions get run in switch?

A

Once a condition is met with the switch method, all ones below get used UNTIL A BREAK!

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

How much does a Switch run for

A

Once met all following cases are operated until BREAK;

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

Switch doesn’t work for what data type?

A

Floats or double

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