Arrays
Loops
Methods
Classes
Random/Scanner
100

What is the method name for returning the length of an Array?

arrayName.length;

100

This loop is known for its use of the i incrementor 

For Loop

100

What type of parameter passing does Java use?

Pass by value

100

Which access modifer makes a attribute/method only visible/useable inside a given class?

Private 

100

How do you create a Random object AND a Scanner object? Include both import and the object creation.

import Java.util.Scanner;

import Java.util.Random;

Scanner scan = new Scanner(System.in);

Random rand = new Random();

200

What index value do arrays start at in Java?

0

200

This statement can be used to end a loop immediately

Break

200

If an object is made up of first name, last name, age, position, and salary, what datatypes would these variables be?

String, String, int, String, int

200

What keyword do you use when accessing a variable inside of a class, especially when figuring out if you're using the class variable name or the parameter name?

this

200

This scanner method is used to geta full String-based input.

scanner.nextLine();

300

Give an example of an int array populated with three values on the whiteboard using only one line. 

int[] numbers = {1, 2, 3}

300

This loop will always run once regardless if the condition is true or false.

Do While Loop

300

What datatype does this method return??
final int MULTI = 2;

public ___ multiple(int num){

___multiple = num * MULTI;

return multiple;

}

integar

300

This is what is called when an object is first created

The Constructor

300

What number range does random.nexInt(2, 27) return?

2 - 26

400

What is the name of the error when trying to access an array element that does not exist?

ArrayIndexOutOfBoundsException

400

Write a while loop that constantly asks the user for String input non-stop until the user enters CEASE AND DESIST IMMEDIATELY! Include your class name and public static void main

import java.util.Scanner;


public class WhileLoopDemo {

    public static void main(String[] args) {

        // Create a Scanner object to read user input

        Scanner scanner = new Scanner(System.in);

        // Declare a String variable to store the user input

        String input = "";

        // Loop until the user enters CEASE AND DESIST IMMEDIATELY!

        while (!input.equals("CEASE AND DESIST IMMEDIATELY!")) {

            // Prompt the user to enter a String

            System.out.print("Enter a String: ");

            // Read the user input and store it in the variable

            input = scanner.nextLine();

            // Print the user input

            System.out.println("You entered: " + input);

        }

        // Close the Scanner object

        scanner.close();

    }

}

400

What is the output?

public class Main{


    public static void main(String[] args){


         int num = 5;


         int[] numberArray = {2, 4, 6, 8, 10};


         changeValues(num, numberArray);


         System.out.println(num);


         for(int i = 0; i < numberArray.length; i++)


              System.out.println(numberArray[i]);


    }


    public static void changeValues(int num, int[] numArray){


         num = 15;


         numArray[2] = 1000;


    }


}

2

4

1000

8

10

400

These are the methods for returning or modifying existing attributes.

Getters and Setters

400

What number range does random.nextDouble() * 39 give? 

0.0 - 38.99...

500

Write a static method that returns the average of ANY given double array.

public static double average(Double[] numArray){

    double sum = 0.0;

    for(int i = 0; i < numArray.length; i++)

         sum += numArray[i];

    return sum / numArray.length;

}

500

Write a for loop that will print out the multiplications table, from 0 - 9, remember to use System.out.print() and System.out.println()! Include your class name and public static void main.

public class Main {

  public static void main(String[] args) {

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

      System.out.print(i + ": ");

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

        System.out.print(j * i + " ");

      }

      System.out.println();

    }

  }

500

Write a method that is called calculateWage() that takes in salary and hours, and returns a double datatype called wage.

public double calculateWage(double salary, double hours){

double wage = salary * hours;

return wage;
}

(int or salary or hours will be accepted)

500

Write a public class method that will return true if two Wealth objects have the same value; assume this class has a public double attribute called money and a public int attribute called age.

public isEquals(Wealth other){

    return(this.money == other.money && this.age == other.age);

500

What type of error is produced when a String is entered with scan.nextInt()?

InputMismatchException