COMP 401 Final Exam Spring 2021. Complete With Answers.
I have not received nor given any unauthorized assistance in completing this
... [Show More] exam.
Signature:
Name:
PID:
The exam has 6 parts for a total of 140 points.
This page intentionally left blank.
Part I: True or False
40 questions, 1 points each, 40 points total.
_F A local variable in a method may not have the same name as an instance variable.
_T Method parameter names serve as valid local variables within the body of a method.
_T The scope of a local variable in a method is limited to the statement block where it is declared.
_F The type of a variable can be changed after it is declared.
T_ A protected instance variable can be directly accessed by methods in a subclass.
F_ When using the factory design pattern, a factory method for creating new instances is usually defined as an instance method.
_F A constructor can not throw an exception.
_T One constructor can invoke another constructor in the same class using the this
keyword as if it were a method name.
_T Class variables can be accessed by instance methods but instance variables cannot be accessed by class methods.
_F A setter method conforming to the Java Beans convention should return the new value of the property.
_F An interface definition can include private or protected methods.
_F An iterator provides a way to access elements of an aggregate object sequentially by exposing its underlying representation.
_F Traversing an array using an integer index incremented as a for-loop variable is an example of the iterator design pattern.
_T An iterator assumes that the underlying collection is not changed or modified while the traversal occurs.
_T An expression can always be used where ever a value is required.
_T Class names, interface names, and enumeration names can all serve as the data type of a variable.
_T In an instance method, the this keyword always provides a reference to the specific instance used to invoke the method.
_T The state of an object is defined by the current values of all of its instance fields.
_T A method's signature is defined by its return type and the sequence of types associated with its parameters.
_F Polymorphic methods with the same name may have different return types.
_T Polymorphic methods with the same name must have distinct method signatures.
_T Enumerations provide a type-safe mechanism for an object property that can be set to one of a distinct set of values.
_T Different classes that implement the same set of interfaces may also have different and additional behavior not declared by those interfaces.
_T Two object references that have the same value always refer to the same object.
_T A derived property is computed as a function of an object's state.
_F The principle of least privilege is not related to the principle of encapsulation.
_F Calculating a derived property each time it is needed is an example of saving time at the expense of space.
_T The state of an immutable object cannot be changed after it is created.
_F A class that implements a subinterface must only provide implementations for methods declared by the subinterface.
_F A subclass inherits private and protected fields and methods from its parent class.
_T All classes implicitly inherit from Object.
_F The catch or specify policy applies to all subclasses of Exception.
F_ In general, you should catch an exception at the earliest point at which the exception can be detected. [Show Less]