Class Structure
Using Objects
ArrayLists
Strings/Loops
Random
100

The method to create an object

What is a Constructor

100

Keyword to create an object

What is new

100

What is the value of this arrayList:

ArrayList<Student> students;

What is null

100

The index of the letter e in word after the 4 spot. Store it in a variable called spot

What is 

int spot = word.indexOf("e", 3);

100

The import statement to use an ArrayList

What is java.util.ArrayList;
200

Access Modifier for an instance variable

What is private

200

Create an object of type Device called computer that calls a constructor with one parameter a String that holds the value laptop

What is 

Device computer = new Device("laptop");

200

Create an empty ArrayList of type Bottle called bottles

What is 

ArrayList<Bottle> bottles = new ArrayList<Bottle>();

200

Loop through a String using an Enhanced Loop to build a new String that is the reverse of the original String

What is

String reverse = "";

for(String letter : word){

    reverse = letter + reverse;

}

200
The main components of a class in order

What are instance variables, constructors, getters, setters, other private methods, toString

300

The last method for every class

What is toString

300

You have an object called student1 in the main method of a Driver class. Print out the name of the student.

What is 

System.out.println(student1.getName());

300

Loop through a list called buildings of type Building and print each building out. Use an Enhanced Loop

What is

for (Building b : buildings){

     System.out.println(b);

}

300

The kind of value return by this line of code:

word1 = "Bat";

word2 = "bat";

word1.compareTo(word2);

What is a negative number

300

The difference between to two remove methods for an ArrayList

What is one removes at an index and returns a boolean. The other one removes the object and returns it. 

400

The header for the final method in a class

What is 

@Override

public String toString()

400

You have a Car object that has an instance variable of type Wheel. The Wheel class has a getType method. Write a line of code to get the type of wheel that car1 has and store it. 

What is 

String wheelType = car1.getWheel().getType();

400

Get the 3rd name in the list called names and change the name to be John.

What is names.get(2).setName("John");

400

What is printed?

int outer = 1;

int total = 0;

while (outer <= 3) {

    int inner = 1;

    while (inner <= 2) {

        total += outer * inner;

        inner++;

    }

    outer++;

}

System.out.println("Final total: " + total);

What is 18

400
Print the last item in the items list but first make sure two things are true. 

if(items != null && items.size()>0){

    System.out.print(items.get(items.size()-1));

}

500

The word this is used for

What is to differentiate the instance variable from the parameter value

500

Write a method to see if two Animal objects are both the same species 

What is

public boolean sameSpecies (Animal other){

      return this.species.equals(other.species);

}

500

Use a loop to remove all movie objects that are inTheaters. They are in a list called movies

What is

for (int i = movies.size()-1; i >=0; i--){

    if(movies.get(i).isInTheaters()){

          movies.remove(i);

     }

}


500

What does this print?

String phrase = "AbC";

String output = "";

int pos = 0;

while (pos < phrase.length()) {

    String current = phrase.substring(pos, pos + 1);

    int count = 0;

    while (count < 2) {

        if (current.equals(current.toUpperCase())) {

            output += current.toLowerCase();

        } else {

            output += current.toUpperCase();

        }

        if (phrase.indexOf(current) % 2 == 0) {

            output += count;

        }

        count++;

    }

    pos++;

}

System.out.println("Final output: " + output);

What is a0a1BBc0c1

500

import java.util.ArrayList;

ArrayList<Integer> nums = new ArrayList<Integer>();

nums.add(2);

nums.add(4);

nums.add(3);

nums.add(7);

int i = 0;

while (i < nums.size()) {

    if (nums.get(i) % 2 == 0) {

        nums.set(i, nums.get(i) / 2);

    } else {

        nums.remove(i);

        i--;

    }

    i++;

}

System.out.println("Final list: " + nums);

What is

Final List: [1,2]