Exam Questions Ch.18 - Inheritance And Lists 5th Edition - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.

Exam Questions Ch.18 - Inheritance And Lists 5th Edition

Chapter 18 - Inheritance and Lists

True/False (12)

  1. A derived class can be more efficient if it can access the underlying data structures of its base class.
  2. If the SortedList class inherited the getEntry method from the LList class, we would have to implement it again.
  3. When defining the SortedList class, writing “? super T” where T is a generic type, restricts flexibility in the type of objects that a sorted list can contain.
  4. SortedList inherits potentially dangerous methods from LList that may compromise the order of the list.
  5. The use of “super” in a method call indicates that we are invoking a version of the inherited class.
  6. If SortedList overrides the lists’s method, the class’s implementation can no longer invoke the method.
  7. If a class inherits a method that is inappropriate, you can override it with a method that throws an exception when called.
  8. A derived class of another class such as LList cannot access or change anything that is private within that class.
  9. The LinkedChainList class is primarily concerned with managing a list while the LinkedChainBase class is also concerned with the integrity of the list.
  10. The ADT sorted list will execute slower if certain key methods in the LinkedChainBase class are declared to be protected.
  11. You cannot use inheritance and maintain efficiency of a base class if protected access is used to grant access to the underlying data structure.
  12. It is very uncommon that more than one implementation of an ADT is possible.

Short Answer (8)

  1. Because SortedList inherits the replace(givenPosition, newEntry) method from LList, the list could be compromised by replacing an entry that destroys the order of the sorted list. One solution is to implement the method within the SortedList class but leave the body of the method blank. Explain why this approach might not be a good idea.
  2. Why should the toArray method that SortedList inherits from LList not be appropriate for our purposes?
  3. How does using protected methods in the LinkedChainBase class help the ADT sorted list operations be more efficient?
  4. How does the ADT Sorted List incorporate the LinkedChainBase class?
  5. The add method in the LinkedSortedList and the LinkedChainBase classes are very similar. What is the major difference between them?
  6. In the LinkedChainBase class, a method for adding a new entry to a sorted list does not require a call to the method isEmpty. Explain.
  7. In the LinkedChainBase class, the getNodeBefore method is similar to the getNodeBefore method in the LinkedSortedList. What is the major difference?
  8. Explain why the add method in the LinkedChainBase class has a worst-case time efficiency of O(n2).

Multiple Choice (24) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.

  1. A subclass is also called a(n)
    1. derived class
    2. composed class
    3. base class
    4. super class
  2. A superclass is also called a(n)
    1. base class
    2. derived class
    3. composed class
    4. subclass
  3. The SortList and LList implementation have a(n) _____ relationship.
    1. has-a
    2. is-a
    3. two-way
    4. bi-directional
  4. Writing “? super T” where T defines a generic type means
    1. any super class of T
    2. any subclass of T
    3. any composed class of T
    4. it is an illegal expression
  5. In the following function header SortedList is _____ from LList.
    public class SortedList<T extends Comparable<? super T>>
    extends LLIST<T> implements SortedListInterface<T>
    1. derived
    2. composed
    3. created
    4. expressed
  6. If the SortedList class inherited the remove by position method from the LList class,
    1. we would not have to implement it again
    2. we would have to implement it again
    3. we would not be able to write it the way we wanted to
    4. none of the above
  7. Because SortedList is derived from LList, you write
    _____.add(newPosition, newEntry)
    to invoke the add operation of the ADT list.
    1. super
    2. this
    3. sub
    4. invoke
  8. To enable a subclass to access data fields by name without giving access to a client, we declare the data fields to be
    1. protected
    2. private
    3. public
    4. limited
  9. To prevent a subclass from overriding protected methods, we declare them to be
    1. final
    2. protected
    3. private
    4. limited
  10. Which method is declared to be protected in the LinkedChainBase class?
    1. addAfterNode
    2. contains
    3. toArray
    4. all of the above
  11. Which method is declared to be protected in the LinkedChainBase class?
    1. addFirstNode
    2. addAfterNode
    3. removeAfterNode
    4. all of the above
  12. When you declare a method to be protected and final, who can access it?
    1. a subclass
    2. a superclass
    3. a client
    4. all of the above
  13. To ensure integrity of a sorted list, we do not allow a subclass to alter the link portion of a node by declaring the method to be
    1. private
    2. protected
    3. limited
    4. public
  14. If you plan for a future subclass to be allowed to manipulate a class’s data fields, provide _____ methods to enable the subclass to do this safely and efficiently.
    1. protected
    2. private
    3. limited
    4. public
  15. If a subclass can directly alter the data fields of the SortedList, the damage could be
    1. malicious and intentional
    2. accidental
    3. both a & b
    4. none of the above
  16. Which method cannot have an identical definition in both LinkedChainList and LList?
    1. replace
    2. isEmpty
    3. toArray
    4. all of the above
  17. Which method cannot have an identical definition in both LinkedChainList and LList?
    1. contains
    2. isEmpty
    3. toArray
    4. all of the above
  18. Which method cannot have an identical definition in both LinkedChainList and LList?
    1. getEntry
    2. isEmpty
    3. toArray
    4. all of the above
  19. Which method cannot have an identical definition in both LinkedChainList and LList?
    1. replace
    2. getEntry
    3. contains
    4. all of the above
  20. In the LinkedChainBase class, the time efficiency of the add method is
    1. O(n2)
    2. O(n)
    3. O(log n)
    4. O(1)
  21. Which method is common to the ADT sorted list but not inherited from LinkedChainBase?
    1. getEntry
    2. add
    3. remove
    4. all of the above
  22. Which method is common to the ADT sorted list but not inherited from LinkedChainBase?
    1. contains
    2. remove
    3. getPosition
    4. all of the above
  23. Which method is common to the ADT sorted list but not inherited from LinkedChainBase?
    1. getEntry
    2. contains
    3. getPosition
    4. all of the above
  24. What issue should you weigh when considering an implementation for an ADT?
    1. execution time
    2. memory use
    3. extensibility
    4. all of the above

Document Information

Document Type:
DOCX
Chapter Number:
18
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 18 - Inheritance And Lists
Author:
Frank M. Carrano

Connected Book

Data Structures with Java 5e Complete Test Bank

By Frank M. Carrano

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party