Booleans and Conditionals
Loops
Methods
Arrays
Mystery
100

What will be the output of this code?

if (10 > 10){

    System.out.println("reached");

}

What is no output?

100

What are two types of loops in Java?

What are any two of while loops, for loops, and do-while loops?

100

True or false, public static void main(String[] args) is a method

What is true?

100

How would you access the "H" element from the array defined by this code?
String[] arr = {"W","O","O","H","O","O"};

What is arr[3]?

100

Which of following pieces of code would print the length of a string called str?

  1. System.out.println(str.length);
  2. System.out.println(str.length());
  3. System.out.println(str.size);
  4. System.out.println(str.size());

What is System.out.println(str.length());?

200

What will be the output of this code?

System.out.println(true || false);

What is true?

200

What will be the output of this code?

int i = 0;
while (i < 5){
  System.out.println(i);
  i++;
}

What is
0
1
2
3
4
 
?

200

How would you call a method named myMethod?

What is myMethod()?

200

Can you add new elements to an array?

What is no?

200

How do you create a Scanner variable that reads input from the terminal?

What is Scanner sc = new Scanner(System.in);?

300

Which comparison operator will return true if two values are not equal?

What is != ?

300

Which of the following is a valid line of code?

  1. while(int i = 0; i < 4; i++) {}
  2. for(10) {}
  3. for (int j = 0; j < 10; j++) {}

What is for (int j = 0; j < 10; j++) {}?

300

What data type will this method return?
public static int myMethod() {/* code */};

What is int?

300

What should replace /* REPLACE */ in the following code to create an empty array of 10 integers?
int[] ints = /* REPLACE */;

What is new int[10]?

300

What are the two common methods for printing out values? No partial credit!

What is System.out.print() and System.out.println()?

400

Double Jeopardy! This question is worth 2x points.

How do you compare two strings?

What is str1.equals(str2)?

400

What comparison operator should this loop use to make the loop print the numbers from 0 to 50?

int i = 0;
while (i /*REPLACE OPERATOR*/ 50){
  System.out.println(i);
  i++;
}

What is <= ?

400

What should replace /* REPLACE */ so the method myMethod takes in an integer called x as a parameter?

public static void myMethod(/*REPLACE*/){/*code*/}

What is int x?

400

Does the following code run without errors?
String[] arr = {"WOO","HOO"};
System.out.println(arr[2]);

What is no?

400

Which of the following is an invalid name for a variable in Java?

  1. _BestCoder
  2. 1stCoder
  3. BESTCODER

What is 1stCoder?

500

What is the output of this code?
System.out.println(true && !(false || true));

What is false?

500

What will be the output of this code?

for (int i = 0; i < -10; i++){
  System.out.println(i);
}

What is no output?

500

What will this code print out, if anything?

myMethod() 
...
public static String myMethod(){
  return "Message"
}

What is no output

500

What should replace /* REPLACE */ in the following code to print out every element of an unnamed integer array called "arr"?
for (/* REPLACE */){
  System.out.println(arr[i]);
}

What is
int i = 0; i < arr.length; i++?

500

Does this code run without errors?

int[] ints = {1, 2, 3};
for(int i : ints) {
System.out.println(i);
}

What is yes?

M
e
n
u