Fun-damentals
Let Me Ask You a Question
One More Time
Strings and Things
Method to the
Madness
100
The error in this code:

int x = 2.0;

What is a data type mismatch?
100
The mistake here:

...
if (x = 1) {
    y++;
}

What is an example of using = instead of ==?
100
The output of the following program:

int n = 0
while (n < 10) {
     System.out.print(n + " ");
     n++
}

What is 0 1 2 3 4 5 6 7 8 9 ?
100
Initializing a String variable s with "chicken".
What is: String s = "chicken";
100
The method header for a program that takes an integer as input and prints out its value
What is public static void print(int x)
200
The value of this expression:
5 / 3
What is 1?
200
The simpler way to write (assuming b is a boolean):
b == false
What is !b
200
The output of the following program:

int n = 0
while (n < 10) {
     System.out.print(n + " ");
}

What is 0 0 0 0 0 0 0 0 0 0....?
200
The value of s4:

String s1 = "1";
String s2 = "2";
String s3 = "3";
String s4 = s1 + s2 + s3;

What is "123"?
200
The error in this code:

public static void main(String[] args) {
   someMethod()
   System.out.println(x);
}

public static void someMethod() {
 double x = Math.random();
}

What is x is not visible outside the method?
300
The value of x:

double dub = 10*Math.PI;
int x = (int) dub;

What is 31?
300
The output of the following program if temp = 30

String report; if (temp < 30) {
    System.out.println("It's cold!");
} else if (temp < 10 {
     System.out.println("It's really cold!");
} else {
     System.out.println("It's fine);
}

What is "It's fine"?
300
The for loop equivalent of:

int n = 0
while (n < 10) {
     System.out.print(n + " ");
    n++
}

What is
The output of the following program:

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

300
The value of s2 after the following:

String s1 = "java is fun";
String s2 = s1.substring(0,3);

What is "jav"?
300
A method taking three integers as inputs and returning them in an array.
What is

public static int[] name(int a, int b, int c) {
    int[] array = {a, b, c};
   return array;
}

400
The error here:

final int BOTTLES = 6;
BOTTLES++;

What is an example of modifying a constant?
400
The value of letterGrade if grade = 99:

String letterGrade = " F";
if ( grade >= 90) { letterGrade = " A"; }
if ( grade >= 80) { letterGrade = " B"; }
if ( grade >= 70) { letterGrade = " C"; }
if ( grade >= 60) { letterGrade = " D"; }

What is "D"
400
A code snippet that tells you if an integer n is prime.
What is

int f = 2;
boolean isPrime = true;
while (!isPrime && f < n) {
     isPrime = (n % f == 0);
     f++;
}

400
The output of the following program:

String name = "Jane";
if (name.toLowerCase() == "jane") {
     System.out.println("You're Jane!");
} else {
    System.out.println("Not Jane!");
}

What is "Not Jane!"?
400
The problem with this method:

public static int half(double a) {
    return a / 2;
}

What is a return type mismatch
500
The value of y after this code executes:

int x = 4;
double y = x / 8;

What is 0?
500
The simpler way to write (assuming b is a boolean and n an integer):

if ( n == 0) {
     b = true;
} else {
     b = false;
}

What is b = (n == 0)?
500
A program that calculates the sum of the even integers between 0 and n.
What is

int total = 0;
for (int i < 0; i < n; i = i + 2) {
     total = total + i;
}

500
The correct way to compare strings s1 and s2
What is s1.equals(s2)?
500
The problem with this method:

public static boolean contains(int[] a, int b) {
   for (int i = 0; i < a.length; i++) {
         if (a[i] == b) {
            return true;
        }
    }
}

What is the method has no return if there is no match.