CS 2114 Final Review questions with answers 2023
When does a class use composition? - When it has a data field that's an instance of another class Give an example of a "has a" relationship. - The Name class has an instance of the String class as a data field What is an adapter class? - Using composition to write a new class that has an instance of your existing class as a data field and defines the methods that you want Define inheritance - enables you to organize classes so that common properties and behaviors can be defined just once for all classes involved (is a relationship) True or False: Constructors are not inherited - True What happens when a data field is private in a superclass? - It's not accessible by name within the definition of a method for any other class, including a subclass What's a final method? - can't be overridden with a new definition in a subclass What's a final class? - you can't use it as a superclass to derive any other class from it (ex: string class) What's multiple inheritance? - when one class is derived from 2 different superclasses? Which one is legal? Student may = new CollegeStudent(); CollegeStudent may = new Student(); - Student may = new CollegeStudent(); (you go from general - specific) What does the clone method do? - takes no arguments and returns a copy of the receiving object What is a collection? - general term for an ADT, contains a group of objects What's an ADT bag? - unordered collection that allows duplicates (does not order contents) ADT list - numbers the items in the collection Do ADT stacks and queues order items? - Yes, they order them chronologically When you remove an item from a stack what gets removed? - the most recently added item When you remove an item from a queue, what gets removed? - the one that was added the earliest What's different about a sorted list? - determines where to place the item in the list (ex: alphabetical order)
Document information
- Uploaded on
- August 9, 2023
- Number of pages
- 3
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers