Mr. Snyder Trivia
Unit 1
Unit 2
Unit 3
Unit 4
100

What is Mr. Snyder's first name?

Kevin

100

What is the java print command?

System.out.println()

100

What operator checks if two values are equal?

==

100

What do we call a method that doesn't return a value?

Void

100

What is an array with multiple rows called?

2D Array

200

How many kids does Mr. Snyder have?

2

200

What data type is used to store whole numbers?

int

200

What operator checks if two values are not equal?

!=

200

What is the term for the special method that initializes an object?

Constructor

200

What is the keyword to create a new array in java?

New

300
What sport does Mr. Snyder coach?

Basketball

300

Consider the code: int x = 4; double y = x / 2;

What is printed if System.out.print(y); is executed?

2.0

300

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

300

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"

300

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}

400

What is Mr. Snyder's favorite food?

Cheeseburgers

400

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?


  1. 3 1.0

  2. 3 1.5

  3. 3.5 1.5

  4. 3.5 1.75


B. 3 1.5

400

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

400

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

400

/* 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];

500

What is Mr. Snyder's favorite color?

Blue

500

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

500

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

500

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

500

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.