If Statements
Loops
Methods
Miscellaneous
Spot the error
100

        int number = 20;

        if(number > 15){

            System.out.println("Welcome to Java");

        }

Welcome to Java

100

Name the three types of loops

While Loop, Do While Loop, and For Loop

100

What two symbols are used in every method

() The left and right parenthesis.

100

What is an example of a line that doesn't end with a semicolon?

Loops, or the opening class block.

100

 while(5 > 4){

            System.out.println("hello");

        }

Infinite Loop

200

The if statement is an example of a _____.
a. sequence structure
b. decision structure
c. pathway structure
d. class structure

b. decision structure

200

What is the best type of loop to use when you know exactly how many times you want the loop to run

For loop

200

Does this line of code contain a method?


Int number = input.nextInt();

Yes, the nextInt() part of the code is a method.

200

What is missing from this code?

While{

System.out.println("Welcome to Java");

}

The condition for the while loop

200

        Scanner input = new Scanner();

        String userInput = input.nextInt();

Missing System.in inside the parameter.
300

>, <, and == are _____.
a. relational operators
b. decision expression
c. unconditional expression
d. boolean expression

a. Relational operators

300

What is the sentinel value in this loop example.

System.out.println("Please keep typing integers until you are done, then type 0 to stop");

0 since it is the number used to end the loop.

300

What is the output of this method

        String name = "Donald";

        System.out.println(name.indexOf("o"));

It will print 1 since the first instance of o is in the one index.

300

What are the possible outputs of this number

int rand = (int)(Math.random() * 10 + 1);

1 through 10

300

        String word = "hello";

        System.out.println(charAt.word(4));

charAt and word should be switched

400

        int number = 20;

        if(number < 15){

            System.out.println("Welcome to Java");

        }        

        else if(number <= 18){

            System.out.println("Welcome to Java");

        }

        else{

            System.out.println("Try again later");

        }

Try again later

400

What will be the last output of this for loop?

        for(int i = 0; i < 10; i++){     System.out.println("Welcome to count number " + i);

            }

Welcome to count number 9

400

What method do we use when we want to create a substring from a string named "word"

word.substring

400

What is the output of this line of code.

System.out.println((int)(2.0 + 5  + 3.0));

10 because it's being cast to an int

400

        for(int i, i < 5, i++){

            System.out.println("Good luck on the test!");

        }

Semicolons should be used instead of commas to separate parts of the for loop.

500

What is the difference between the "else if" and "else" statements.

Else if is used to add another option whereas else is used as a final option that happens if all others fail.

500

       What is the ouput of this code 

        int i = 0;

        do{    

          System.out.println("Hello"); 

          i++;

        }

        while(i > 10);

The word hello once because the condition isn't met.

500

What does this print?

String s = "marco polo";
System.out.println(s.substring(0,3));

mar

500

What is the difference between a logic error and a runtime error.

A logic error is when the code runs but gives you an incorrect output. A runtime error is when the code crashes during runtime due to an error.

500

        int counter = 0;

        do while(counter < 10){

            System.out.println("The count is at " + counter);

            counter ++;

        }

The do and the while parts need to separated 
M
e
n
u