What is Mr. Snyder's first name?
Kevin
What is the java print command?
System.out.println()
What operator checks if two values are equal?
==
What do we call a method that doesn't return a value?
Void
What is an array with multiple rows called?
2D Array
How many kids does Mr. Snyder have?
2
What data type is used to store whole numbers?
int
What operator checks if two values are not equal?
!=
What is the term for the special method that initializes an object?
Constructor
What is the keyword to create a new array in java?
New
Basketball
Consider the code: int x = 4; double y = x / 2;
What is printed if System.out.print(y); is executed?
2.0
Consider the code:
boolean a = true; boolean b = false; System.out.print(a && b);
What is printed?
A. false
B. true
C. a != b
D. Error
B. true
Consider:
public class Dog { private String name; public Dog(String n) { name = n; } }
Dog myDog = new Dog("Rex");
What does myDog contain?
A. name = null
B. name = "Rex"
C. name = ""
D. name = "Dog"
B. name = "Rex"
int[] nums = {2, 4, 6, 8, 10};
nums[0] = 5;
nums[2] = 9;
Which of the following represents the contents of nums after the code segment has been executed?
A. {2, 4, 6, 8, 10}
B. {5, 4, 9, 8, 10}
C. {5, 9, 6, 8, 10}
D. {2, 9, 6, 8, 10}
B. {5, 4, 9, 8, 10}
What is Mr. Snyder's favorite food?
Cheeseburgers
Consider the following code segment.
double a = 7;
int b = (int) (a / 2);
double c = (double) b / 2;
System.out.print(b);
System.out.print(" ");
System.out.print(c);
What is printed as a result?
3 1.0
3 1.5
3.5 1.5
3.5 1.75
B. 3 1.5
Consider the code:
boolean a = true; boolean b = false; System.out.print(a && b);
What is printed?
A. true
B. a && b
C. false
D. Error
C. false
Consider:
public class Student { private String name; private int age; public Student(String studentName, int studentAge) { name = studentName; studentAge = age; } }
Student myStudent = new Student("Bobby", 25);
What is the state of myStudent?
A. name = "Bobby", age = 0
B. name = "Bobby", age = 25
C. name = null, age = 0
D. name = null, age = 25
A. name = "Bobby", age = 0
/* missing code */
numbers[1] = 5;
numbers[2] = 10;
Which of the following code segments can be used to replace /* missing code */ so that the code segment sets the contents of the array to {0, 5, 10}?
A. int[] numbers;
B. int[] numbers = new int[1];
C. int[] numbers = new int[2];
D. int[] numbers = new int[3];
D. int[] numbers = new int[3];
What is Mr. Snyder's favorite color?
Blue
int a = 3;
double b = a + 2.5;
int c = (int)(b / 2);
double d = c + 0.75;
System.out.print(c + " " + d);
What is printed as a result?
A. 1 1.75
B. 2 2.75
C. 2 3.0
D. 3 3.75
B. 2 2.75
boolean result = false;
if (n >= 10)
{
result = true;
}
if (n <= 50)
{
result = true;
}
System.out.println(result);
Which of the following best describes the behavior of the code segment?
A. It prints true for all possible values of n.
B. It prints false for all possible values of n.
C. It prints true if n is between 10 and 50, inclusive, and prints false otherwise.
D. It prints false if n is between 10 and 50, inclusive, and prints true otherwise.
A. it prints true for all possible values of n
Consider:
public class Car { private String model; private int year; public Car(String m, int y) { model = m; year = y; } }
Car myCar = new Car("Tesla", 2024);
Which statement best describes myCar?
A. model = null, year = 0
B. model = "Tesla", year = 2024
C. model = "Car", year = 2024
D. model = "Tesla", year = 0
B. model = "Tesla", year = 2024
int[] grades = {70, 85, 90, 95, 100};
grades[2] *= 3; // Line 2
grades[3] += 5; // Line 3
Which of the following best describes the behavior of lines 2 and 3 in the code segment?
A. Line 2 triples the first element in the array and line 3 adds 5 to the second element.
B. Line 2 triples the third element in the array and line 3 adds 5 to the fourth element.
C. Line 2 triples the fourth element in the array and line 3 adds 5 to the fifth element.
D. Lines 2 and 3 do not change the contents of the array.
B. Line 2 triples the third element in the array and line 3 adds 5 to the fourth element.