Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
CMSC 132 Midterm 1 Exam Questions With 100% Correct Answers | Verified | Latest Update Provide an example that illustrates procedural abstraction - Correct Answer-One example: a function that sorts data, but we don't indicate how to sort it. the private access specifier - Correct Answer-Mention one Java language feature that allow us to implement encapsulation. Yes, as finalize() is called when an object is garbage collected - Correct Answer-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 Answer-should you use an enumerated type vs. a class? Briefly explain.
Typology: Exams
1 / 6
Provide an example that illustrates procedural abstraction - Correct Answer-One example: a function that sorts data, but we don't indicate how to sort it. the private access specifier - Correct Answer- Mention one Java language feature that allow us to implement encapsulation. Yes, as finalize() is called when an object is garbage collected - Correct Answer-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 Answer- should you use an enumerated type vs. a class? Briefly explain.
Both the View and Controller. - Correct Answer-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 Answer-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 Answer- throw new IllegalArgumentException("Invalid Argument"); true - Correct Answer-Is it possible to define enumerated types that have private constructors? false - Correct Answer-When designing object-oriented systems verbs in a problem
statement may represent classes/variables needed in the design. Shallow copy - Correct Answer-Which kind of copying (reference, shallow or deep) is performed by the default clone method every class has? Procedural abstraction - Correct Answer- Describes operation without indicating how to implement it. Initializer - Correct Answer-The word that best describes what a constructor method does is: When the class is loaded - Correct Answer-A static initialization block is executed: Never - Correct Answer-We can override a final method Can implement an interface - Correct Answer- An abstract class
extend interface - Correct Answer-An interface can only Abstract if abstract method(s) from the super class are not defined in the subclass. - Correct Answer-class extending an abstract class will become: true - Correct Answer-Can you create an array from abstract class?(true of false ) true - Correct Answer-You can not instantiate an abstract class or an interface (true of false) None of the above - Correct Answer-55% code coverage implies finally - Correct Answer-The_______block always executes when the try block exits Checked Exception like ClassNotFoundException, IOException - Correct Answer-Exception which are checked at Compile time called ___
checked, as a program should do something about this situation - Correct Answer-A program reads a web address and tries to connect to the site. What kind of exception (check or uncheck) do you believe we should use when an invalid web address is provided? Briefly explain. There were two kinds of employee: salaried and hourly. Using composition made it easier to change pay scales. - Correct Answer-Provide a brief description (no code is necessary) of the employee example discussed in lecture that illustrated why we prefer composition over inheritance. Definition of methods and instance variables are not allowed in an interface - Correct Answer-is the difference between an interface and an abstract class? need to deal with check exceptions (either declare or throw them). - Correct Answer-What is the difference between a check and an unchecked exception. When the object is garbage collected. - Correct Answer- When is the finalize() method invoked?
- Correct Answer-Model--->application data, View-->visual interface, Controller--->user interaction Static block is executed when class is loaded. - Correct Answer-what is the difference between a static initialization block and a non-static initialization block?