Relational Operators
Syntax
If/Else
For-Loops
Scope
100

True or false?

4 >= 10

False

100

What is the syntax for a print statement?

System.out.print("Hello!");
100

What do we put in parentheses when writing an if-statement?

e.g. if (what is this thing) {}

Condition

100

What are the three parts of a for-loop?

Initialization, Condition, Update

100

The space where a variable exists

What is scope?

200

List all the relational operators you remember (at least 4):

>=, <=, >, <, !=, ==, &&, ||

200

What is the syntax for an if-else statement?

if (condition) {

} else {

}

200

How many statements can be executed in a single conditional?

e.g. 

if (condition) {

    // Statement

} else if (condition) {

    // Statement

} else {

    // Statement

}

1 statement

200

What is the difference between:

i++ 

and 

i = i + 1 ?

There is no difference :)

200

Will x have a scope outside the loop?

for (int x = 0; x < 20; x *= 3) {

}

No
300

How are logical operators different from other relational operators (like >=) ?

They can only be used with boolean values.

300

What is the syntax of a for-loop?

for (initialization; condition; update) {

}

300

Why would you use an else-if?

When you have more than one condition you want to check

300

How many times will the loop run?

for (int i = 1; i < 10; i++) {

    // more code

}

9 times

300

Can variable 'pies' be used in the inner loop?

for (int pies = 20; pies > 0; pies--) {

    for (int chicken = 2; chicken < 5; chicken ++) {

    }

}

Yes

400

Difference between = and ==

What is the difference between assignment and checking equality?

400

What 3 problems are wrong with the syntax of this print statement:

system.out.print("hello! \")

1. System has a capital S

2. Need another ", the escape sequence means that it is not the end of the String.

3. Need a semi-colon

400

What values of x would make the else clause run?

if (x % 2 == 0) {

} else {

}

Any odd number

400

How many times would the loop run?

for (int x = 12; x > 0; x++) {

    // more code

}

Infinite times

400

Where is the variable in-scope?

// Line A

for (int i = 0; i < 4; i++) {

    if (i > 2) {

        // Line B

    } else { 

        System.out.println("Hooray!");

    } // Line C

} // Line D

B, C
500

Evaluate (4 % 2 == 1) && ((37 * 53 + 6 % 3) == 2) 

false


**remember short-circuited evaluation!

fun fact: 37*50 + 6 % 3 == 1850 

500

What is the syntax for an if-else-if-else conditional?

if (condition) {

} else if (condition) {

} else { 

}

500

Which values of x would make the else-if run?

if (x > 100) {

} else if (x < 200) {

} else {

}

Any value less than or equal to 100

500

How many times would this loop run?

for (int rows = 0; rows < 10; rows++) {

    System.out.println("I am a Jedi!");

    rows++;

}

5 times

500

Where is the variable 'a' in scope?

// Line A

if (dogs > 0) { // Line B

    for (double a = 0; a < 20.0; a += 3) {

        dogs++; // Line C

    } // Line D

} else {

    // Line E

} // Line F

C