Test Corrections
- Question 4 Selection with variables x and y
- Question 14 Vehicle interface getMileage
- Question 16 append method with two 1D int arrays
- Question 23 manipulate method and animals List
- Question 25 RBox interfaces
- Question 30 scramble method with String and int parameters
- Question 33 Print sum after while loop
- Question 34 Point and Circle Classes
- Question 35 Print result after while loop
- Question 38 Compound Boolean expression with variables x and y
Question 4 Selection with variables x and y
What is printed as a result of executing the code segment?
I chose answer B which was 2.3333 but the value was an integer so this is not a possible answer. The correct answer was C which was 2 because when 7 is divided by 2, you get 2.3333 however, it has to be an integer so it's 2.
Question 14 Vehicle interface getMileage
Which of the following can be used to replace / expression / so that getTotalMileage returns the total of the miles traveled for all vehicles in the fleet?
I chose the answer D, however the answer is E which is v.getMileage() because it follows the form of object.method(parameters) where v is the object, getMileage is the method, and the parameters is empty.
Question 16 append method with two 1D int arrays
Which of the following expressions can be used to replace / index / so that append will work as intended?
I chose answer B which was k, but the right answer was answer D, k + a1.length, because it needed to have the a1.length included to have the first index as a1.length.
Question 23 manipulate method and animals List
What will the contents of animals be as a result of calling manipulate?
The code segment is supposed to take the element that starts with "b" and move it to index 1. This means that the correct answer is ["bear", "zebra", "bass", "cat", "koala", "baboon"].
Question 25 RBox interfaces
Which of the interfaces, if correctly implemented by a Box class, would be sufficient functionality for a user of the Box class to determine if one Box can fit inside another?
I and II only is the correct answer because choice I gives access to the height, width, and depth of the box with the get methods. Choice II provides smallerHeight, smallerWidth, and smallerDepth methods that let you know whether the box is smaller.
Question 30 scramble method with String and int parameters
What value is returned as a result of the call scramble("compiler", 3)?
The correct answer is "ilercom" because the howFar is 3 so the first letter is actually the fourth because the paramater is howFar + 1. The length of the word is 8 - 7 letters so it only returns "ilercom".
Question 38 Compound Boolean expression with variables x and y
Which of the following is equivalent to the expression given above?
Answer A is the correct answer because it will be true if y is greater than 10000 or x is between 1000 and 1500 and if y is greater than 10000, the value will be true. It will still be true if y is not greater than 1000 and x is still in between 1000 and 1500.