CSE 2221 Midterm 2 Test Guide 2025. | Exam Revision Questions And
Correct Answers | Graded A+ | 2025 Update |
Precondition - Answer characterizes the responsibility of the program
that calls the method (the client)
Post-condition - Answer characterizes the responsibility of the program that implements the
method (the implementer)
Parameter Mode - Answer Part of the contract that specifies the way a method might change
the value of the corresponding argument.
Clears - Answer A parameter mode. Resets the parameter to its initial value (like 0)
Restores - Answer The default parameter mode. The parameter value is unchanged after
method execution.
Replaces - Answer A parameter mode. The value of the parameter may change, but the
method's behavior doesn't depend on its initial value
Testing - Answer Proving code has an error
Debugging - Answer Finding and fixing an error in the code
Receivers - Answer Distinguished formal parameters, implicit arguments
Overloading - Answer Having methods/variables all with the same name. The actual
constructor is inferred by the program from the argument type.
, .copyFrom() - Answer Copies values not references
.newInstance() - Answer Has the advantage that you don't need to know the name of any
implementation class to call the method
.compareTo() - Answer Has all the >,< signs pointing in the same direction
Primitive types - Answer Types built-in to Java, refers to an object
Reference types - Answer types that store references to instances of classes. The variable
points to the memory location of the data
Primitive variable - Answer Variable of primitive type
Reference variable - Answer Variable of reference type
Reference value - Answer the memory address (like a serial number)
Object value - Answer the actual data in memory
---> - Answer We use an arrow instead of "=" to remind ourselves that a variable is a
reference variable
= - Answer Copies reference values into other reference variables during assignment
(creating aliasing). Aliasing in NaturalNumbers: When passing a NaturalNumber as an argument,
it passes a reference, so any changes to the object within a method affect the original object unless
explicitly copied.
Correct Answers | Graded A+ | 2025 Update |
Precondition - Answer characterizes the responsibility of the program
that calls the method (the client)
Post-condition - Answer characterizes the responsibility of the program that implements the
method (the implementer)
Parameter Mode - Answer Part of the contract that specifies the way a method might change
the value of the corresponding argument.
Clears - Answer A parameter mode. Resets the parameter to its initial value (like 0)
Restores - Answer The default parameter mode. The parameter value is unchanged after
method execution.
Replaces - Answer A parameter mode. The value of the parameter may change, but the
method's behavior doesn't depend on its initial value
Testing - Answer Proving code has an error
Debugging - Answer Finding and fixing an error in the code
Receivers - Answer Distinguished formal parameters, implicit arguments
Overloading - Answer Having methods/variables all with the same name. The actual
constructor is inferred by the program from the argument type.
, .copyFrom() - Answer Copies values not references
.newInstance() - Answer Has the advantage that you don't need to know the name of any
implementation class to call the method
.compareTo() - Answer Has all the >,< signs pointing in the same direction
Primitive types - Answer Types built-in to Java, refers to an object
Reference types - Answer types that store references to instances of classes. The variable
points to the memory location of the data
Primitive variable - Answer Variable of primitive type
Reference variable - Answer Variable of reference type
Reference value - Answer the memory address (like a serial number)
Object value - Answer the actual data in memory
---> - Answer We use an arrow instead of "=" to remind ourselves that a variable is a
reference variable
= - Answer Copies reference values into other reference variables during assignment
(creating aliasing). Aliasing in NaturalNumbers: When passing a NaturalNumber as an argument,
it passes a reference, so any changes to the object within a method affect the original object unless
explicitly copied.