yes
Which of the following best describes why this method does not compile?
It is possible to reach the end of the method without returning a value.
Which of the following expressions can be used to replace /* index */ so that append will work as intended?
k + a1.length
Which of the following would be the best specification for aCircle method isInside that determines whether aPoint lies inside this Circle?
public boolean isInside(Point p)
Which of the following represents the contents of the arrayarr after the code segment is executed?
{1, 1, 3, 3, 5, 5, 7}
Which of the following represents the contents of arr as a result of executing the code segment?
{1, 2, 3, 5, 6, 7, 7}
System.out.print(3 * x); What is printed as a result of executing the code segment?
27
Consider the following code segment. int[] arr = {1, 2, 4, 0, 3}; for (int i : arr) { System.out.print(i); } Which of the following code segments will produce the same output as the code segment above?
3 only
MenuItem one = new MenuItem(5.0); one.makeItAMeal(); System.out.println(one.getPrice()); What, if anything, is printed as a result of executing the code segment?
6.5
System.out.println(outer + inner); } } How many values will be printed when the code segment is executed?
60
System.out.println("D"); } What, if anything, is printed when the code segment is executed?
B
Which of the following changes should be made so that method findLongest will work as intended?
Insert the statement lenCount = 0; between lines 12 and 13.
Assume that the boolean variables a, b, c, and d have been declared and initialized. Consider the following expression. !( !( a && b ) || ( c || !d )) Which of the following is equivalent to the expression?
( a && b ) && ( !c && d )
Assume that a and b have been defined and initialized as int values. The expression ! ( ! (a != b ) && (b > 7) ) is equivalent to which of the following?
(a!=b)||(b<=7)
Which of the following code segments will properly update the variable grade based on a student's performance on the bonus questions?
1 only
The classify method works as intended for some but not all values of the parameter volume. For which of the following values of volume would the correct value be returned when the classify method is executed?
115
Which of the following can be used to replace /* missing code */ so that isDecreasing will work as intended?
2 only
Which of the replacements will have the same behavior as the original version of inRangeMessage ?
2 only
What value is returned as a result of the call mystery(4) ?
21
Which of the following best describes the contents of numbers after the following statement has been executed? int m = mystery(n);
All values in positions m+1 through numbers.length-1 are greater than or equal to n.
Assume that nums has been declared and initialized as an array of integer values. Which of the following best describes the value returned by the call mystery(nums) ?
An index of a value that occurs most often in nums
Which of the following changes, if any, can be made to line 4 so that the method will work as intended?
Changing j <= arr.length; to j < arr.length;
Which of the following changes should be made so that the class definition compiles without error and the methodraisePrice works as intended?
Replace line 14 with price += surcharge;.
The method findLongest does not work as intended. Which of the following best describes the value returned by a call to findLongest ?
It is the number of occurrences of the value target in nums.
The following code segment appears in a method in a class other than Something. Something s = new Something(); Something.increment(); Which of the following best describes the behavior of the code segment?
The code segment creates a Something object s. The class Something's static variable count is initially 0, then increased by 5, then increased by 1.
Consider the following two code segments. Code segment II is a revision of code segment I in which the loop header has been changed. Which of the following best explains how the output changes from code segment I to code segment II?
The code segments print the same values but in a different order, because code segment I iterates from 1 to 5 and code segment II iterates from 5 to 1.
numItems = newNum; } } Which of the following best identifies the reason the class does not compile?
The updateItems method is missing a return type.
The deposit method is intended to increase the account balance by the deposit amount and then return the updated balance. Which of the following code segments should replace /* missing code */ so that the deposit method will work as intended?
balance = balance + amount; return balance;
Consider the following statement. boolean x = (5 < 8) == (5 == 8); What is the value of x after the statement has been executed?
false
The code does not work as intended. Assume that the variable randomNumber has been properly declared and initialized. Which of the following initializations forrandomNumber will demonstrate that the code segment will not work as intended?
randomNumber = 0.70;
Consider the following code segment, which traverses two integer arrays of equal length. If any element of arr1 is smaller than the corresponding (i.e., at the same index) element of minArray, the code segment should replace the element of minArray with the corresponding element of arr1. After the code segment executes, minArray should hold the smaller of the two elements originally found at the same indices in arr1 and minArray and arr1 should remain unchanged.
remove lines 5-8
The calculateFee method is intended to calculate the total fee for renting a car. The total fee is equal to the number of days of the rental, days, times the daily rental rate plus the number of miles driven, miles, times the per mile rate. Which of the following code segments should replace /* missing code */ so that the calculateFee method will work as intended?
return (days * dailyRate) + (miles * mileageRate);
Consider the following Boolean expression in which the int variables x and y have been properly declared and initialized. (x <= 10) == (y > 25) Which of the following values for x and y will result in the expression evaluating to true ?
x = 10 and y = 30
System.out.print("Third"); } What is printed as a result of executing the code segment?
third
System.out.println(alpha == beta); System.out.println(alpha == delta); What is printed as a result of executing the code segment?
true false true