Answered! Q16. Which of the following statements is true? a. The class Object, which is derived from the class Throwable, is the…

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

 As the number of questions are too much, I will not answer them all please upload them separetly but I will answer half of them. Hope you will find it useful. Here goes:

16 (b) If you see the inheritance tree of this, Object is followed by Throwable and then followed by Exception.

17 (a) Yeah, that is one thing to talk about. We all have been told that abstract classes can’t be instantiated but with one condition they can be, the subclass should give or fully implement the abstract class.

18 (b) Nah, that is a fact a subclass does not inherit the private members of its parent class. But in case when the superclass has public or protected methods for accessing the private memebers of the class, these can be used by the subclass.

19 (a) Yes, that is true. Exception class is the superclass of all exception classes. FACT !

20 (a) True ! Checked exception are the exceptions which the programmer should catch. They are meant to be explicitly catched in try-catch block.

21 (a) Yeah, this method doesn’t take any parameters and gets another copy on an existing vector.

22 (a) Yes, there is one and that method’s signature is –> void clear()

23 (b) Nope, that is contanied in java.util

24 (c) java.util (Above fact check ! )

25 (b) copyInto, with the signature as –> void copyInto(Object[ ] anArray)

26 (c) Actually clear() method removes all the elements from a list. But I don’t see clear() in the option, closest guess would be choice c only.

27 (a) That is the distinguishing difference between Vectors and Arrays. Arrays don’t grow but vectors can grow or shrink that to during program execution.

28 (b) False ! Clearly visible from it’s name only. UnorderedArrayList should arrange list elements in no particular order.

29 (a) The lastElement() method is used to return the last component of the vector.

30 (a) as earlier mentioned ( Question 27 check )

31 (a) joining the last to the first is technically making a circle i.e. in this case circular linked list.

That would be all from my side, please repost half of the question otherwise it seems like spam ! If you have any doubts let me know in the comments.

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