Back to marketplace

Practice Test(s)

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

Practice Test 01 What is the largest number of comparisons needed to perform a binary search on an array with 42 elements? 2 5 6 41 42

Back (Answer)

6

#2
Front (Question)

Practice Test 01 Which of the following are valid arrays? I. int[] coolArray = {1, 2, 3}; II. int[] threeThings = {1.0, 2.0, 3.0}; III. int[] = {“1”, “2”, “3”}; I only II only III only I and II I and III

Back (Answer)

I only

#3
Front (Question)

Practice Test 01 What is the output of the following program? • hel • hello • hellow • Error • None of the above

Card front image
Back (Answer)

• Error Correct! Specifically, the <= in the for loop results in an attempt to access data that is out of the array’s bounds.

#4
Front (Question)

Practice Test 01 What values will the array contain after the following the code is run? int[] someArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; for (int i = someArray.length - 2; i >= 0; i-=2) { someArray[i] = someArray[i] - 5; } • {6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4} • {1, -3, 3, -1, 5, 1, 7, 3, 9, 5, 11} • {1, 3, 5, 7, 9, 7, 5, 3, 1, -1, -3} • {-4, 1, -2, 3, -4, 5, -6, 7, -8, 9}

Back (Answer)

2. {1, -3, 3, -1, 5, 1, 7, 3, 9, 5, 11}

#5
Front (Question)

Practice Test 01 What is the proper way to compare String values in Java? • The == operator • The .equals() String method • The = operator • The | operator

Back (Answer)

• The .equals() String method

#6
Front (Question)

Practice Test 01 What result would be printed given these commands: SomeFavorites mystery = new SomeFavorites(); mystery. listSomething(); mystery. anotherThing();

Card front image
Back (Answer)

42 42

#7
Front (Question)

Practice Test 01 What are the values of the variables x, y, and z after this code snippet runs? int x = 0; int y = 10; int z = 20; x = y; y = y * 2; z = 30; • x = 0, y = 10, z = 30 • x = 0 , y = 20 , z = 20 • x = 10, y = 20, z = 30 • x = 10, y = 10, z = 30

Back (Answer)

• x = 10, y = 20, z = 30

#8
Front (Question)

Practice Test 01 Your robot Baymax seems to have a bug in his battery. The problem is Baymax will only stay on if his battery is at 100%. Anything lower than 100% and Baymax shuts off. What is the bug in this code snippet? Hint : Baymax represents his battery life as a decimal number between 0 and 1. • There is a syntax error in Baymax’s baymaxIsOn method. The else statement must also have a conditional expression. • We are trying to represent batteryLife (a decimal number) with an int variable. We should instead be using a double variable. • Baymax’s chargeBattery and useBattery methods will error. Java does not allow you to add an int and a double. • Baymax’s baymaxIsOn method can NEVER return True.

Card front image
Back (Answer)

• We are trying to represent batteryLife (a decimal number) with an int variable. We should instead be using a double variable.

#9
Front (Question)

Practice Test 01 What would be a correct way to instantiate this 2D array? • int[][] table = {1, 0, 1, 5, 3, 8}; • int[][] table = { {1, 0, 1, 5}, {3, 8} }; • int[][] table = { {1, 0, 1, 5}, {3, 8, 0, 0} };

Card front image
Back (Answer)

• int[][] table = { {1, 0, 1, 5}, {3, 8} };

#10
Front (Question)

Practice Test 01 Given the following: double[][] something = { {2.5, 6.8, 8.3}, {6.1, 10.2, 1.3, -2.5}, {1.1, 2.3, 5.8, 13.21, 34.55} } What is the value of something[1][2]? • 8 • 1 • 3 • 3 The array does not have an element at that location.

Back (Answer)

1.3

#11
Front (Question)

Practice Test 01 What is the proper way to get the number of items in an ArrayList called list? • list.length • list.size • list.length() • list.size() 5.

Back (Answer)

• list.size()

#12
Front (Question)

Practice Test 01 What is the output of the following lines? • int x = 24;* • System.out.println(“The total is “ + x + x);* • The total is 24 • The total is 2424 • The total is 48 • The total is x + x

Back (Answer)

• The total is 2424

#13
Front (Question)

Practice Test 01 Which expression is true? • true && !true • !false || !true • true && false • false || false || !true

Back (Answer)

• !false || !true

#14
Front (Question)

Practice Test 01 What will this program print if the value of grade is 80?

Card front image
Back (Answer)

C

#15
Front (Question)

Practice Test 01 What will the values of x and y be after this code segment runs?

Card front image
Back (Answer)

x = 99 y = 199

#16
Front (Question)

Practice Test 01 Refer to the following code segment: double myDouble = 1/4; System.out.println(“1 / 4 = “ + myDouble); The output of the code is: 1 / 4 = 0.0 The student wanted the output to be: 1 / 4 = 0.25 Which change to the first line of their code segment would get the student the answer that they wanted? • int myDouble = 1/4; • double myDouble = (double) 1/4; • double myDouble = (int) 1/4; • double myDouble = (int) (1.0/4.0);

Back (Answer)

2. double myDouble = (double) 1/4;

#17
Front (Question)

Practice Test 01 What will the following code print?

Card front image
Back (Answer)

Java

#18
Front (Question)

Practice Test 01 What is wrong with the following code? ArrayList list = new ArrayList(); list.add(1); System.out.println(list.get(0)); • It will throw an IndexOutOfBoundsException. • You cannot use int as the type in an ArrayList. • list is a reserved word, so you can’t call the variable that. • You need to define the new ArrayList on a new line of code. • Nothing. The above code is correct.

Back (Answer)

• You cannot use int as the type in an ArrayList

#19
Front (Question)

Practice Test 01 What does this method call output? public double doubleNumber(double myNumber) { return (double) (int) myNumber * 2; } doubleNumber(7.8); 16 • 6 • 0 This method is improperly written. Answered

Back (Answer)

14.0

#20
Front (Question)

Practice Test 01 Consider the following code segment: String str = “I am”; str += 10 + 3; String age = “years old”; System.out.println(str + age); What is printed as a result of executing the code segment? • I am103years old • I am13years old • I am 103 years old • I am 13 years old

Back (Answer)

• I am13years old

#21
Front (Question)

Practice Test 01 What would this method call output? divideByTen(340)

Card front image
Back (Answer)

34

#22
Front (Question)

Practice Test 01 What is the output of this method call? public String wordScramble(String myWord) { myWord.substring(2) + myWord.charAt(3) + “dot”; } wordScramble(“polkadot”) • “dotpolka” • “lkadotkdot” • “olkadotldot” • This method call will error.

Back (Answer)

• This method call will error

#23
Front (Question)

Practice Test 01 What kind of error does this method cause? myMethod(“Frog”); • Compile Time Error: Missing return value • Runtime Error: String index out of range • Compile Time Error: Unexpected return value • Compile Time Error: Syntax Error in method definition

Card front image
Back (Answer)

• Runtime Error: String index out of range

#24
Front (Question)

Practice Test 01 What does this method call output? someMethod(3,1)

Card front image
Back (Answer)

10