Question & Answer: Q1. A(n) ____ is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time……

Q1. A(n) ____ is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time.
a. design plan
b. algorithm
c. process plan
d. structured program

Q2. Polymorphism is the ability to use the same expression to denote different operations.
a. true
b. false

Q3. In black-box testing, the internal workings of the algorithm or function are known.
a. true
b. false

Q4. White-box testing relies on the internal structure and implementation of a function or algorithm.
a. true
b. false

Q5. Which of the following categorizes a member of a class?
a. private
b. open
c. safe
d. static

Q6. public Clock()
{
setTime(0, 0, 0);
}

What is the name of the class that the constructor above belongs to?
a. Clock
b. public
c. setTime
d. It cannot be determined from the information given.

Q7. The three fundamental stages a program goes through are: development, use, and ____.
a. implementation
b. maintenance
c. analysis
d. requirements gathering

Q8. In ____ copying, each reference variable refers to its own object.
a. shallow
b. deep
c. method
d. object

Q9. When no object of the class type is instantiated, static data members of the class fail to exist.
a. true
b. false

Q10. Encapsulation is the ability to create new data types from existing data types.
a. true
b. false

Q11. Suppose a class Car and its subclass Honda both have a method called speed as part of the class definition. rentalH refers to an object of the type Honda and the following statements are found in the code:

rentalH.cost();
super.speed();

What will the first statement in the situation described above do?
a. The cost method in Honda will be called.
b. The cost method in Car will be called.
c. Nothing will be called since the code will not compile as a result of multiple definitions of speed.
d. Overloading will be used to determine which cost method to use.

Q12. The class Throwable is derived from the class Exception.
a. true
b. false

Q13. When is a finally{} block executed?
a. Only when an exception is thrown by a try block.
b. Only when there are no exceptions thrown.
c. At the end of a program.
d. Always after the execution of a try block, regardless of whether or not an exception is thrown.

Q14. A subclass can directly access protected members of a superclass.
a. true
b. false

Q15. Java supports both single and multiple inheritance.
a. true
b. false

Q16. Which of the following statements is true?
a. The class Object, which is derived from the class Throwable, is the superclass of the class Exception.
b. The class Exception, which is derived from the class Object, is the superclass of the class Throwable.
c. The class Throwable, which is derived from the class Object, is the superclass of the class Exception.
d. The class Throwable, which is derived from the class Exception, is the superclass of the class Object.

Q17. You can instantiate an object of a subclass of an abstract class, but only if the subclass gives the definitions of all the abstract methods of the superclass.
a. true
b. false

Q18. Private members of a superclass can be accessed by a subclass.
a. true
b. false

Q19. If in the heading of a catch block you declare an exception using the class Exception, then that catch block can catch all types of exceptions because the class Exception is the superclass of all exception classes.
a. true
b. false

Q20. A checked exception is any exception checked for by the programmer.
a. true
b. false

Q21. The method clone in the class Vector returns a copy of the vector.
a. true
b. false

Q22. There is a method in the class Vector that removes all elements of the vector.
a. true
b. false

Q23. The class Vector is contained in the package java.swing.
a. true
b. false

Q24. Which package is the class Vector located?
a. java.io
b. java.lang
c. java.util
d. java.text

Q25. Which of the following methods copies the elements of a vector into an array?
a. clone
b. copyInto
c. toArray
d. fromVector

Q26. The method ____ removes the elements from the list, leaving it empty.
a. deleteElements
b. removeAt
c. clearList
d. deleteList

Q27. A Vector object can shrink during program execution.
a. true
b. false

Q28. The elements of an object of the class UnorderedArrayList are always sorted.
a. true
b. false

Q29. Which method would you most likely use to find the element in the last location of the vector?
a. lastElement
b. elementAt
c. indexOf
d. lastIndexOf

Q30. Which limitation of arrays does a vector overcome?
a. arrays cannot increase in size, vectors can
b. arrays cannot be passed as parameters to methods, vectors can
c. arrays cannot be searched, vectors can
d. there is a method that returns the length of a vector, there is no way to find the length of an array

Q31. A linked list in which the last node points to the first node is called a circular linked list.
a. true
b. false

Q32. Header and trailer nodes can complicate insertion and deletion algorithms.
a. true
b. false

Q33. Which answer most accurately completes the following sentence: A linked list is made up of ____.
a. classes
b. nodes
c. addresses
d. memory variables

Q34. Linked lists built forward or backward are identical in every way.
a. true
b. false

Q35. while(current!=null)
current=head.link;

The above statement traverses a linked list.
a. true
b. false

Q36. In the class LinkedListClass, the search method is declared as ____.
a. public
b. private
c. abstract
d. protected

Q37. In an ordered list, we need to modify only the algorithms (as implemented for a regular linked list) for the ____, insert, and delete operations.
a. copy
b. compare
c. traverse
d. search

Q38. Which of the following should be used to traverse a list?
a. the head of the list
b. the tail of the list
c. a reference variable not in the list
d. any node in the list

Q39. Searching, inserting, and deleting require traversal of the linked list.
a. true
b. false

Q40. Searching through a linked list or inserting an item in a linked list requires a ____ of the list.
a. review
b. deletion
c. copy
d. traversal

Q41. private int func3(int m, int n) {
if (m < n)
return 0;
else
return 1 + func3(m-n, n);
}

Refer to the code above. What is the value of func3(-5, 1)?
a. -5
b. 0
c. 1
d. 5

Q42. The overhead associated with iterative methods is greater in terms of both memory space and computer time, when compared to the overhead associated with executing recursive methods.
a. true
b. false

Q43. private int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);
}

Which of the following statements about the code above is always true?
a. func2(m,n) = func2(n, m) for m >= 0
b. func2(m,n) = m * n for n >=0
c. func2(m,n) = m + n for n >=0
d. func2(m, n) = n * m for n >=0

Q44. A method is called directly recursive if it calls another recursive method.
a. true
b. false

Q45. Recursion starts with the base case.
a. true
b. false

Q46. public static int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

Refer to the code above. What is the output of exampleRecursion(0)?
a. 0
b. 3
c. 9
d. 27

Q47. In the base case, the solution is obtained through a call to a smaller version of the original method.
a. true
b. false

Q48. In reality, if you execute an infinite recursive method on a computer it will execute forever.
a. true
b. false

Q49. Every recursion definition must have zero or more base cases.
a. true
b. false

Q50. private int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

What precondition must exist in order to prevent the code above from infinite recursion?
a. m > = 0 and n >= 0
b. m >= 0 and n >= 1
c. m >= 1 and n >= 0
d. m >= 1 and n >= 1

Expert Answer

 Q1. b. algorithm

Q2. True

Q3. False

Q4. True

Q5. a. Private

Q6. a. Clock

Q7. c. analysis

Q8. a. shallow

Q9. b. false

Q10.  b. false

Q11. a. The cost method in Honda will be called.

Q12. a. true

Q13.  d. Always after the execution of a try block, regardless of whether or not an exception is thrown.

Q14. a. True

Q15. b. False

Still stressed from student homework?
Get quality assistance from academic writers!