Score: 52/66

This is an image

Corrections:

Question 7

This is an image

Topic 9.3: Overriding Methods

The correct answer is D: I and III. I will result in a compile-time error because method B has not been created yet. III also results in error because a1 is a private int so it can only be accessed by class A and not class B even if it is a subclass.

Question 8

This is an image

Topic 3.6: Equivalent Boolean Expressions

The correct answer is D: Expression I and expression II evaluate to the same value only when A and B differ. When A and B are different, I and II will both be false as it cannot be both A and B at the same time.

Question 13

This is an image

Topic 3.5: Compound Boolean Expressions

The correct answer is A: x. If an expression is x or y but also x it has to be x.

Question 15

This is an image

Topic 2.6: String Objects - Concatenation, Literals, and More Topic 2.7: String Methods

The correct answer is A: containsArt (“rattrap”, “similar”, “today”). The ar in similar and the t combine in string all when the 3 words are added together creating the substring “art” even though none of the words contain art.

Question 16

This is an image

Topic 8.2: Traversing 2D Arrays

The correct answer is C: Line 8 should be changed to for (int[] row : arr). This assigns row 8 to the row of the 2d array while the pervious line tries to set a row to a column.

Question 27

This is an image

Topic 7.4: Developing Algorithms Using ArrayLists

The correct answer is B: {1, 2, 2, 3, 3, 4, 5}. The loop causes j to increase by increments of 2 instead of 1. It skips over the integer in spot 2 and 4 therefore it does not get rid of the repeating 2s and 3s.

Question 28

This is an image

Topic 7.4: Developing Algorithms Using ArrayLists

The correct answer is D: When scores is [8, 8, 4, 3, 3, 6] and low_score is 3. The method does not work with consecutive low scores, therefore it will not detect the 3 as the low score.

Question 35

This is an image

Topic 4.2: For Loops

The correct answer is D: When scores is [8, 8, 4, 3, 3, 6] and low_score is 3. The method does not work with consecutive low scores, therefore it will not detect the 3 as the low score.

Question 38

This is an image

Topic 3.5: Compound Boolean Expressions

The correct answer is B: II only. The else if loop ensures that if the value is not less than 0, it is also tested to be greater than 100 and then prints out of range which is the same as the original function. III includes or equal to and I returns in range for values less than 0.

Question 42

This is an image

Topic 2.7: String Methods Topic 4.3: Developing Algorithms Using Strings

The correct answer is E: mystery (“noon”). The method extracts the letters in reverse order through the for loop. It then compares str to temp and if they are the same it returns true. Since noon is the same forward and backward, the algorithm will return true.

Question 52

This is an image

Topic 5.5: Mutator Methods

The correct answer is B: Replace line 14 with price += surcharge;. In order to add subcharge to price, the price needs to then become the previous price plus subcharge making price += subcharge the correct function to do so. Since it is a void mutator method, and not an accessor method, the method should not return a value.

Question 54

This is an image

Topic 10.1: Recursion

The correct answer is D: recurMethod(“edcba”). The recursion tests to see if the letters are in reverse alphabetical order. It continues going through pairs of letters and removing the first if it does not find that the first letter is closer to the front of the alphabet. Once there is one character remaining, the function completes and prints true.

Question 56

This is an image

Topic 7.4: Developing Algorithms Using ArrayLists

The correct answer is E: There should be an else before the statement k++;. Without the else before k++, k continues increasing no matter what happens in the if statement causing the function to skip values and miss duplicates.

Question 60

This is an image

Topic 6.4: Developing Algorithms Using Arrays

The correct answer is C: The last element of the returned array (result [result.length − 1] ) may not have the correct value. Shuffle method does not work properly.

Notes

  • substring: characters within a string
  • compile-time error: error in syntax
  • run-time error: error in code execution
  • zero parameter constructor: requires no argument
  • (int[] row : arr) used to assign row to an array
    • for 2d arrays

What to work on

  • arrays!
    • how rows and columns assigned in 2d arrays
    • making of array lists
  • boolean
    • read the question carefully
    • take time walking through logic
  • methods
    • look at each part carefully
    • read problem and see what it is exactly asking