CSAP Review – 100 Sample Multiple Choice Questions 1. Object Oriented Programming (A) (B) (C) (D) 2. makes programs more reliable.

simulates real life. uses a lot of intimidating vocabulary, which is not as bad as it sounds. is all of the above.

The actions in a Java class are called (A) (B) (C) (D) procedures. functions. methods. subroutines.

3.

Which of the following Math class features do not use any parameters or arguments? (A) (B) (C) (D) PI E final Both A and B

4.

What is the value of result in the following statement? int result = Math.pow(3,4); (A) (B) (C) (D) 12 81 64 4

For questions 5-8 use the following Bank class information. It contains the headings of the methods in the Bank class, along with a description. public Bank() // default constructor starts checking and savings account with zero dollars. public Bank(double c, double s) // parameter creates an object with c dollars in checking and s dollars in savings.

public double getChecking() // returns the checking account balance public double getSavings() // returns the savings account balance public double getCombined() // returns the combined balance of the checking and savings account public void changeChecking(double amount) // alters the balance of the checking account by the amount parameter public void changeSavings(double amount) // alters the balance of the savings account by the amount parameter public void closeChecking() // alters the checking account balance to zero public void closeSavings() // alters the savings account balance to zero

5.

The methods in the Math class are (A) (B) (C) (D) class methods. object methods. expression methods. variable methods.

6.

The methods in the Bank class are (A) (B) (C) (D) class methods. object methods. expression methods. variable methods.

7.

Access to methods of the Bank class requires

(A) (B) (C) (D) 8.

using a statement, like Bank.getSavings(); using a statement, like Bank.getSavings; the creation of one or more Bank objects. using the get method.

What is the output of the following program segment? Bank tom; tom = new Bank(); Bank sue; sue = new Bank(); tom.changeChecking(1000); sue.changeChecking(1500); System.out.println("sue: " + sue.getSavings()); System.out.println("tom: " + tom.getSavings()); (A) (B) (C) (D) tom: sue: sue: 1000.0 sue: 1500.0 1500.0 tom: 1000.0 0.0 tom: 0.0

Error message

9.

Assume that rand is an object of the Random class. Which of the following statements generates a random integer in the [400..1600] range? (A) (B) (C) (D) int number = rand.nextInt(1600) + 400; int number = rand.nextInt(1200) + 400; int number = rand.nextInt(1600); int number = rand.nextInt(1201) + 400;

10.

The kind of output created by an object of the DecimalFormat class is determined by (A) object. (B) (C) (D) the type of parameter used with the construction of a new DecimalFormat using the format method. using the output method. all of the above.

11.

A conditional statement is

0. a program statement that requires input from the keyboard.(A) (B) (C) (D) 12.0.0. double sales = 200000.0. What is the output of the following program segment? double bonus = 500.0. (A) (B) (C) (D) Bonus: 50. System.0 The End Bonus: 500.0. double sales = 200000. .0) bonus += 250. What is the output of the following program segment? double bonus = 500. System.0) System. double sales = 200000.0 The End Bonus: 750.out.out.out.println("The End").println("Bonus: " + bonus). What is the output of the following program segment? double bonus = 500. if (sales >= 300000.0. System.println("Bonus: " + bonus).0 The End Bonus: 500.0 The End Bonus: 750. (A) (B) (C) (D) Bonus: 50. any program statement with an unary operator.println("Bonus: " + bonus).0.0 The End No output 13.0 The End No output 14. any program statement with a binary operator.println("The End"). a program expression that evaluates to true or false. if (sales >= 300000. System.out.out. if (sales >= 300000.0) bonus += 250.

0 (C) Bonus: 750. (A) (B) (C) (D) 16. What is the value of num at the conclusion of the following program segment? char qwerty = 'B'. } .println(n1 + " " + n2).bonus += 250.0 (D) No output What is the output of the following program segment? int n1 = 100. case 'B': num += 2. case 'C': num += 3.out. n2 = n1. case 'D': num += 4. if (n3 > 0) { n2 = n1. int n2 = 200. int num = 100. } else { n1 = n2. n1 = n2.0. int n3 = n1 / n2. switch(qwerty) { case 'A': num ++. } System.0 (B) Bonus: 500. (A) Bonus: 250. 100 200 200 100 200 100 200 100 15.

case 'B': num += 2. case 'D': num += 4. break. case 'C': num += 3. } (A) (B) (C) (D) 100 101 102 Error message 18.(A) (B) (C) (D) 17. int num = 100. What is the output of the following program segment? int count = 1. What is the output of the following program segment? . switch(qwerty) { case 'A': num ++.println(count). k < 100. break. k++) count++. System. for (int k = 0. 100 102 109 Error message What is the value of num at the conclusion of the following program segment? char qwerty = 'B'. (A) (B) (C) (D) 99 100 101 102 19. break.out.

k < 9. do { num3 = num1 % num2. for (int k = 1. k <= 5.out. (A) (B) (C) (D) 20. } System. } } while (num3 != 0). int num2 = 108. (A) (B) (C) (D) sum: 8 sum: 9 sum: 16 sum: 25 21.out. k+=2) sum += k. (A) (B) 0 6 .println("sum: " + sum). for (int k = 0.out. count2++. if (num3 == 0) System. What is the output of the following program segment? int num1 = 120. int num3 = 0. else { num1 = num2. 6 7 6 7 7 8 3 3 What is the output of the following program segment? int sum = 0. k++) { count1++.int count1 = 1. num2 = num3.println(count1 + " " + count2). System.println(num2). int count2 = 2.

(C) (D) 22.out. method3(). method2(). 12 36 A class method call (A) (B) (C) (D) requires that the class identifier precedes the method identifier. may be called with the method identifier only in certain circumstances. } public static void method3() { System. 23. uses the class identifier only for readability.println("Calling method 3").println("Calling method 2"). What is the output of the following program? public class Q39 { public static void main(String args [ ]) { method1(). } public static void method2() { System.out.out. } public static void method1() { System. } } (A) Calling method 1 Calling method 2 Calling method 3 Calling method 1 Calling method 3 Calling method 2 (B) . is only possible after a new object is constructed.println("Calling method 1").

(C) method 1 method 3 method 2 Error message (D) 24.out.println("Calling method " + n). } public static void method3(int n) { System. } public static void method1(int n) { System. method2(3).println("Calling method " + n).out. } } (A) Calling method 1 Calling method 2 Calling method 3 Calling method 1 Calling method 3 Calling method 2 (B) .out. method3(2). } public static void method2(int n) { System. What is the output of the following program? public class Q41 { public static void main(String args [ ]) { method1(1).println("Calling method " + n).

} public static void method2(int n) { System.println("Calling method " + n).println("Calling method " + n). } public static void method1(int n) { System. Q42. } } (A) Calling method1 Calling method2 Calling method3 Calling method1 Calling method3 Calling method2 method1 method2 (B) (C) .out.println("Calling method " + n).(C) method 1 method 3 method 2 Error message (D) 25.out.method1(int n = 1 ). Q42.method3(int n = 3). } public static void method3(int n) { System.method2(int n = 2). What is the output of the following program? public class Q42 { public static void main(String args [ ]) { Q42.out.

method3 (D) 26.10 25 * 10 (B) 25 + 10 = 35 25 . int q) { int result = p / q.println(Calc.println(p + " . int q) { int result = p * q. int q) { int result = p + q.println(Calc.y)). System. System. System. System. } public static void div(int p.y)). System. Error message What is the output of the following program? public class Q44 { public static void main(String args [ ]) { int x = 25.div(x.10 = 15 25 * 10 = 250 (C) 35 15 250 . System.out. int y = 10.y)).out.add(x. } public static void mul(int p.mul(x.sub(x.y)).println(p + " + " + q + " = " + result). } } class Calc { public static void add(int p.out.println(Calc. System.out.out. } } (A) 25 + 10 25 .println(p + " / " + q + " = " + result).println(Calc.out." + q + " = " + result). int q) { int result = p .out.out.q. } public static void sub(int p.println(p + " * " + q + " = " + result). System.

a method identifier followed by a dot and an object identifier. 28. An object is (A) (B) (C) (D) one instance of a class. 29. a method identifier followed by a dot and a class identifier. it is not necessary to pass information to the methods. Object methods are typically used when (A) (B) (C) (D) only a single copy of the class needs to be loaded multiple copies or instances of a class are required. 31. a method identifier followed by a dot and a class identifier. an object identifier followed by a dot and a method identifier. it is not necessary to pass information to the methods. Piggy tom = new Piggy(). Piggy = new tom(). . a method that accesses class attributes. only return methods are used in a class. another word for a class. an object identifier followed by a dot and a method identifier. tom = new Piggy. a method identifier followed by a dot and an object identifier. 30. 32. a class with static methods. Calling an object method requires using (A) (B) (C) (D) a class identifier followed by a dot and a method identifier.26 / 10 (D) 27. Which of the following statements shows correct syntax to create an object of the Piggy class? (A) (B) (C) (D) Piggy new tom = Piggy(). Calling a class method requires using (A) (B) (C) (D) a class identifier followed by a dot and a method identifier. Error message 25 / 10 = 2 2 Class methods are typically used when (A) (B) (C) (D) only a single copy of the class needs to be loaded multiple copies or instances of a class are required. only return methods are used in a class.

What is an overloaded constructor? (A) A constructor with too many program statements. (B) is a parameter method. . (D) is a parameter method. 37. When is a constructor called? (A) (B) (C) (D) Each time the constructor identifier is used in a program statement During the instantiation of a new object During the construction of a new class At the beginning of any program execution 34. (C) is a no-parameter method. (C) is a no-parameter method. 36. (B) is a parameter method. (B) A second constructor with the same constructor heading as the first constructor. 35. which is called automatically during the instantiation of a new object. available to methods of the same class and other classes. A default constructor (A) is a no-parameter method. Access to private data or private methods is (A) (B) (C) (D) restricted to methods of the same class. Inheritance is the process of (A) (B) using classes in the established standard Java Language library. which is called automatically during the instantiation of a new object. A parameter constructor (A) is a no-parameter method. (C) A second constructor with a different identifier than the first constructor. which is called automatically during the instantiation of a new object. (D) is a parameter method. 38. not an issue because the program will not compile. which is called automatically during the instantiation of a new object. (D) A second or other multiple constructor with a different signature than any other constructor.33. using features from an existing class. restricted to methods of other classes.

a static class. is (A) (B) (C) (D) a static class. whose members can all be used by a newly declared class. (C) Use the super keyword followed by the superclass identifier. is (A) (B) (C) (D) 40. How is information passed from the subclass constructor to the superclass constructor? (A) The superclass constructor is automatically called before the subclass constructor. (D) dividing a program into multiple related files for each class in the program. If a subclass has the same method identifier as a superclass method. An established class. which process the data. a subclass. A class.. (D) Use the new operator inside the subclass constructor to instantiate the superclass. a subclass. 39. A subclass has access to the data attributes of a superclass (A) (B) (C) (D) if the superclass data is declared protected. (B) Use the super keyword followed by a parameter list for the superclass. inside the same module. which can use all the features of an established class. (A) (B) a compile error message will result. overloaded. a superclass. 44. only if the primary program class is declared public. overloaded. Which identifier shows up both in the superclass and the subclass? (A) (B) (C) (D) The superclass identifier The subclass identifier The class identifier containing the main method The constructor identifier 42. 41. if the superclass data is declared private or protected. in all cases due to inheritance. a logic error will result. a superclass.(C) combining data and the methods. 43. .

the superclass method will be used. The Boolean expression A >= B is equivalent to which of the following expressions? (A) (B) (C) (D) (E) not (A > B) not (B >= A) not (A < B) A != B A <= B 48. Which of the following columns is the correct truth table for (A or B) or A ? A T T F F B T F T F (A) T T T T (B) T F T F (C) T F F F (D) F F T T (E) T T T F 47. for all values of A and B. Which of the following columns is the correct truth table for (A or B) and B ? A T T F F B T F T F (A) T T T T (B) T F T F (C) T T F F (D) F F T T (E) F T F T 46. only when B is true. 50. The Boolean expression (A && B) && !(A && B) evaluates to . The Boolean expression A > B is equivalent to which of the following expressions? (A) (B) (C) (D) (E) not (B > A) not (A <= B) not (A != B) B>A B >= A 49. whenever either A is true or B is true. The Boolean expression (A and B) or A is true (A) (B) (C) (D) (E) only when A is true. the subclass method will be used. only whenever both A is true and B is true.(C) (D) 45.

out. if (a > 100) { if (a < 50) b = 1000. must execute some process at least one time. false in all cases.print(b). true in all cases. 52. What is the output of the program segment below? int a.(A) (B) (C) (D) (E) 51. do all of the above. must check the loop condition before the loop body is executed. do all of the above. (A) (B) 1000 2000 .. true whenever only A is true or only B is true. true whenever both A is true and B is true. must execute some process at least one time. else b = 3000. 53. } System.while loop is ideal for loop structures that (A) (B) (C) (D) repeat some process a fixed number of times. } else { if (a > 150) b = 2000. b. true whenever either A is true or B is true. must check the loop condition before the loop body is executed. The do. else b = 3000. a = some mystery int. The for loop is ideal for loop structures that (A) (B) (C) (D) repeat some process a fixed number of times.

3000 The value of b cannot be determined without knowing the value of a. p. x++. System. } p += 2.out. p = 1.println(x + y). System. do { q = p. How many ampersands (&) are displayed by the program segment below? int n. y. What is the last output by the following program segment? int x.(C) (D) 54. q. while (q < n) { q += 2. } while ( p < n). x = 1.print("&"). } } (A) (B) (C) (D) 4 5 6 7 55.out. while (y < 3) { y++. while (x < 3) { y = 1. n = 5. .

int grade do { ( prompt and get user input for grade ) } while (grade < 0 || grade > 100). where Y means to repeat the .. You want this program to prevent the user from entering any grades that are outside the range of [0. The user is prompted in some manner to enter 'Y'. Which of the following program segments will only accept the desired input? I. Assume that you are executing a program segment. II. which repeats until user input states to stop. int grade do { ( prompt and get user input for grade ) } while ( !(grade >= 0 && grade <= 100) ). which will enter grades and average them. 'y'.(A) (B) (C) (D) 56. (A) (B) (C) (D) (E) I only II only I & II only II and III only I and III only 57. 'N' or 'n'.100]. 1 2 3 5 Assume that you are writing a program. int grade do { ( prompt and get user input for grade ) } while ( !(grade < 0) || !(grade > 100) ). III.

boolean ok. I only II only III only I and II only I. } while (notOK).program segment and N means to stop execution. (A) (B) (C) (D) (E) 58. do { ( prompt user and get input for choice ) ok = (choice == 'Y' || choice == 'y' || choice == 'N' || choice == 'n'). char choice. Which of the following program segments will only accept the desired input I. boolean notOK. boolean notOK. III. char choice. . char choice. } while (!ok). do { ( prompt user and get input for choice ) notOK = (choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n'). } while (notOK). II and III with a combination of Computer colors are created ____________________________ values. II. do { ( prompt user and get input for choice ) notOK = (choice != 'Y' || choice != 'y' || choice != 'N' || choice != 'n').

public class Java1314 . elements. (C) data structure.java below. Segment2 list[] = new int[100]. What is the output of program Java1314. (B) data structure with LIFO access. list = new int[100]. elements of the same type. Consider the two program segments below. Segment1 declares list incorrectly. of the same or different data types. which allows transfer between internal and external storage. Segment1 declares list correctly. (D) data structure with one. Consider the program segment below. green and blue red. Both Segment1 and Segment2 declare list correctly. yellow and blue blue. or more. int list[]. How many integers can be stored in the list array (A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution 61. called fields.(A) (B) (C) (D) 59. or more. Segment1 int list[]. green and yellow blue. green and white An array is a (A) data structure with one. 60. list = new int[100]. Segment2 declares list correctly. Both Segment1 and Segment2 declare list incorrectly. Which of the following is a true statement about the comparison of Segment1 and Segment2? (A) (B) (C) (D) 62. red. Segment2 declares list incorrectly.

length.5}.4. k++) System.{ public static void main(String args[]) { int list[] = {1. k < list.3. What is the output of the program below? public class Java1326 { public static void main(String args[]) { int matrix[ ][ ].out. for(int p = 0. matrix = new int[3][4].2. } } (A) list[0] = 0 list[1] list[2] list[3] list[4] list[0] = 1 list[1] list[2] list[3] list[4] list[1] = 1 list[2] list[3] list[4] list[5] = = = = = = = = = = = = 1 2 3 4 2 3 4 5 2 3 4 5 (B) (C) (D) list[1] = 2 list[2] = 3 list[3] = 4 list[4] = 5 Compile Error (E) 63. p++) { . for (int k = 1.println("list[" + k + "] = " + list[k]). p < 3.

out.print(matrix[p][q] + " "). matrix = new int[3][4]. q < 4.out. p < 3. } System.print(matrix[q][p] + " "). } } (A) 0 0 0 0 0 0 0 0 0 0 0 0 Compile Error (B) 0 0 0 0 0 0 0 0 0 0 0 0 (C) 0 0 0 0 0 0 0 0 0 0 (D) 64. . p++) { for(int q = 0. } } (A) 0 0 0 0 0 0 0 0 0 0 0 0 Error message (B) 0 0 0 0 0 0 0 0 0 0 0 0 (C) 0 0 0 0 0 0 0 0 0 0 (D) 65. __________ is the principle of breaking up a program into smaller.for(int q = 0.println(). q++) System. What is the output of the program below? public class Java1327 { public static void main(String args[]) { int matrix[ ][ ].out. } System. for(int p = 0.out.out. q++) System. System.println().println(). manageable program modules.out. System. q < 4.println().

combines both data and the methods that act upon the data in the same module. Encapsulation Inheritance Polymorphism Divide and conquer is a user-defined data type. 69.(A) (B) (C) (D) 66. which is a member of a class. inheritance. all of the above. Methods are (A) (B) (C) (D) action modules that process data. Instantiation is the moment that (A) (B) (C) (D) memory is allocated for a specific object of a class. 68. An object (A) (B) (C) (D) is a user-defined data type. Object Oriented Programming is characterized by using (A) (B) (C) encapsulation. combines both data and the methods that act upon the data. is one instance of a more general data type. class variables that store information. . memory is allocated for a specific object. instance variables. 70. none of the above. instances of a class. is both A and B. a program compiles correctly. polymorphism. A class (A) (B) (C) (D) 67. 71. The data in a class are also called (A) (B) (C) (D) attributes. fields. a program is ready for execution. is both A and B. is one instance of a more general data type.

the initial value of the simple data type's variable is copied. When objects are used for parameter passing. the initial values of the object instantiation information are copied. 74. 77. requires using the new operator as well as one String parameter. neither a void method nor a return method. 73. a new object of the same class as the parameter object is instantiated. (D) testing a program without using any actual data.(D) 72. The creation of a String object (A) (B) (C) (D) requires the new operator. (C) thinking about programming features without concern about the implementation of these features. the memory reference where the variable values are stored is copied. total number of data attributes used by an object. all of the above. 75. (B) storing information in private data fields. (A) (B) (C) (D) the current values of the data attributes of the object are copied. a new object of the data type is instantiated. 76. all of the above. Information hiding is the concept of (A) declaring all significant data as private. . When simple data types are used for parameter passing. The scope of an object is the (A) (B) (C) (D) size of the memory allocated for an object. called during the instantiation of a new object. the memory reference where the object information is stored is copied. can be done with or without the new operator. range of accessing member methods. (A) (B) (C) (D) the actual current value of the simple data type's variable is copied. A constructor is (A) (B) (C) (D) a method with the same identifier as the class identifier. period during which an object is defined and allocates memory to store values. is always done without the new operator.

78. s2 and s3 are String objects. Assume that s1. II and III 79. s2 = "Mambo". k++) if (intArray[k] == searchNumber) found = true. } Why is this implementation of the Linear Search algorithm is considered undesirable? . return found. (A) (B) (C) (D) String s1 = "Mambo". s3 = s1 + s2. String s3 = new String("Mambo").concat("Hello"). Which of the following declarations is correct? I. What information will be stored in string3 as a result of the statement below? String string3 = "100" + "200". public boolean linearSearch(int searchNumber) { boolean found = false. II. concat(s1. String s2. I only I and II only II and III only I. Which statement(s) demonstrate(s) string concatenation? (A) (B) (C) (D) s1 = s2. (A) (B) (C) (D) The String value "100200" The int value 100200 The int value 300 The String value "300" 80.length. III. k < intArray. for (int k = 0. Consider the linearSearch method below. Both A and B 81.s2).

q < intArray. How will the Integers be arranged after a call to whatSort? . 82. How will the Integers be arranged after a call to whatSort? (A) (B) (C) (D) 83. q < intArray. public void whatSort() { for (int p = 1.length. Data will be arranged in ascending order. p++) for (int q = 0. intArray[q] = intArray[q+1]. } } Assume that intArray stores a random list of integers prior to calling whatSort. (D) It will return the wrong result if the searchNumber is not found. intArray[q] = intArray[q+1]. intArray[q+1] = temp. The smallest integer will be stored in the first array element. Data will be arranged in descending order.length-p. The largest integer will be stored in the last array element. } } Assume that intArray stores a random list of integers prior to calling whatSort.length-1. (C) It will only return the correct result if the first array element is the searchNumber. public void whatSort() { for (int q = 0. Consider method whatSort below. (B) It will only return the correct result if the last array element is the searchNumber. p < intArray.(A) Searching will continue after a match for searchNumber is found. q++) if ( intArray[q] > intArray[q+1]) { int temp = intArray[q]. q++) if ( intArray[q] > intArray[q+1]) { int temp = intArray[q]. intArray[q+1] = temp. Consider method whatSort below.

it depends on how method whichOne is called. Variable size represents the number of elements in intArray. k < size-1. (B) inserts number into the array. int number) { for (int k = size-1. } Method whichOne (A) deletes number from the array. Consider method whichOne below. } Method whichOne (A) deletes number from the array. Consider method whichOne below. . k > index. (B) inserts number into the array. (C) either deletes number or inserts number. Data will be arranged in ascending order. (D) either deletes number or inserts number. it depends on how whichOne is called. The largest integer will be stored in last array element. it depends on the value of index. 85. Assume that index represents the array location where a new array elements needs to be deleted or an existing array element needs to be deleted. intArray[index] = number. k--) intArray[k] = intArray[k-1]. public void whichOne(int index. (C) either deletes number or inserts number. Variable size represents the number of elements in intArray. size--.(A) (B) (C) (D) 84. Assume that index represents the array location where a new array elements needs to be deleted or an existing array element needs to be deleted. k++) intArray[k] = intArray[k+1]. public void whichOne(int index. The smallest integer will be stored in the first array element. Data will be arranged in descending order. int number) { for (int k = index.

q++) . The smallest integer will be stored in the first array element.length.temp). Assume that method swap exists. (D) The Selection Sort is always faster than the Bubble Sort. either deletes number or inserts number. q++) if (intArray[q] < intArray[temp]) temp = q. public void selectionSort() { for (int p = 0. Assume that method swap exists. for (int q = p+1. How does the Selection Sort compare to the Bubble Sort in execution efficiency? (A) (B) (C) data. which swaps the array elements of intArray according to the provided index parameters. p < intArray.length-1. 87. Consider method selectionSort below. The largest integer will be stored in last array element. if (intArray[p] != intArray[temp]) swap(p. Consider method selectionSort below. p++) { int temp = p. p++) { int temp = p. How will the Integers be arranged after a call to selectionSort? (A) (B) (C) (D) Data will be arranged in ascending order. p < intArray. The Bubble Sort is always faster than the Selection Sort. public void selectionSort() { for (int p = 0. which swaps the array elements of intArray according to the provided index parameters. } } Assume that intArray stores a random list of integers prior to calling selectionSort.length.(D) 86. it depends on the value of index. for (int q = p+1. The Selection Sort is usually faster than the Bubble Sort with random The Selection Sort is only faster than the Bubble Sort with sorted data. Data will be arranged in descending order. 88.length-1. q < intArray. q < intArray.

temp). 180. 170. otherwise it executes every loop. if (intArray[p] != intArray[temp]) swap(p. 140. (D) If the data is sorted already. 190. } } Assume that intArray stores a random list of integers prior to calling selectionSort. because the Linear Search is faster than the Binary Search with sorted data. (C) The Selection Sort continues to make comparisons until every comparison pass is finished. because the Binary Search is always faster than the Linear Search. (B) The Regular Selection Sort continues sorting. 150. 160. 90. 91. the Selection Sort never starts. The smallest integer will be stored in the first array element. 200} How many comparisons are made by a Binary Search method to find number 130? (A) (B) (C) (D) 2 3 4 5 . 110. The largest integer will be stored in last array element. because the Binary Search only works with sorted data. (B) Yes.if (intArray[q] > intArray[temp]) temp = q. Is the Binary Search always preferred over the Linear Search. Assume that intArray contains the following set of sorted integers. (D) No. {100. (C) No. 120. 130. Data will be arranged in descending order. unlike the Linear Search. and why? (A) Yes. because the Binary Search can search any type of data. Data will be arranged in ascending order. the Smart Selection Sort stops. How does the Selection Sort behave after all the data is sorted in an array? (A) It stops making comparisons. just like the Smart Bubble Sort. How will the Integers be arranged after a call to selectionSort? (A) (B) (C) (D) 89.

92. int b) { if (a <= b) { .99} How many comparisons are made by a Binary Search method to determine that number 50 is not in the list? (A) (B) (C) (D) 2 3 4 5 93.88.33. Assume that intArray contains the following set of sorted integers. {11. (B) Every method call will be completed.22. int b) { if (a <= b) { System. } } What will be displayed by the method call count(10. Public static void count(int a.out.20)? (A) (B) (C) (D) 10 11 20 20 11 12 19 19 12 13 18 18 13 14 17 17 14 15 16 16 15 16 15 15 16 17 14 14 17 18 13 13 18 19 12 12 19 20 20 11 10 11 95.print(a + " ").66. even if interrupted by another recursive call.77. (C) Incomplete recursive calls are executed in a LIFO sequence.55. Count(a+1. b). Consider the count method below. Public static void count(int a. Consider the count method below. Which of the following statements is a/are fundamental recursion concept(s)? (A) All recursive methods require an exit or base case.44. (D) All of the above 94.

else return m09(n-1). What value will be returned by the call m10(5) ? public static int m10 (int n) { if (n == 1) return 25.out. System. else return n + m10(n-1).count(a+1. } } What will be displayed by the method call count(10.print(a + " "). } (A) (B) (C) (D) 1 5 25 125 97.20)? (A) (B) (C) (D) 96. 10 11 20 20 11 12 19 19 12 13 18 18 13 14 17 17 14 15 16 16 15 16 15 15 16 17 14 14 17 18 13 13 18 19 12 12 19 20 20 11 10 11 What value will be returned by the call m09(5) ? public static int m09 (int n) { if (n == 1) return 25. What value will be returned by the call m11(1) ? public static int m11(int n) { . } (A) (B) (C) (D) 5 39 125 195 98. b).

} (A) (B) (C) (D) 1 11 30 120 . } (A) (B) (C) (D) 5 20 24 120 100. What value will be returned by the call m14(5. 1 10 50 75 What value will be returned by the call m13(5) ? public static int m13 (int n) { if (n == 1) return 1. int b) { if (a == 0) return 0. else return n * m13(n-1). else return b + m14(a-1. } (A) (B) (C) (D) 99. else return n + m11(n+1).b).6)? public static int m14 (int a.if (n == 5) return 0.

Sign up to vote on this title
UsefulNot useful