CMSC 132 MIDTERM 1(Complete solutions)
Provide an example that illustrates procedural abstraction correct answers One example: a function that sorts data, but we don't indicate how to sort it. the private access specifier correct answers Mention one Java language feature that allow us to implement encapsulation. Yes, as finalize() is called when an object is garbage collected correct answers You would like to generate a message when an object is garbage collected. Would you be able to generate that message using the finalize() method? Briefly explain When you have a fixed number of instances (e.g., phases of the moon). correct answers should you use an enumerated type vs. a class? Briefly explain. Both the View and Controller. correct answers For our first project (ClearCellGame) which component (of the Model-View-Controller) was provided? Using static defines a single constant for the whole class, whereas non-static defines a constant per object. correct answers What is difference between making a variable final static vs. just final? In other words, what is the difference between the following two declarations? Briefly explain. Throw illegal argument exception with a string "Invalid Argument" correct answers throw new IllegalArgumentException("Invalid Argument"); true correct answers Is it possible to define enumerated types that have private constructors? false correct answers When designing object-oriented systems verbs in a problem statement may represent classes/variables needed in the design. Shallow copy correct answers Which kind of copying (reference, shallow or deep) is performed by the default clone method every class has? Procedural abstraction correct answers Describes operation without indicating how to implement it. Initializer correct answers The word that best describes what a constructor method does is: When the class is loaded correct answers A static initialization block is executed: Never correct answers We can override a final method Can implement an interface correct answers An abstract class
Document information
- Uploaded on
- May 29, 2024
- Number of pages
- 2
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers