1|Page
OSU CSE 2221 MIDTERM 2 STUDY GUIDE 2025|
BRAND NEW ACTUAL EXAM WITH 100% VERIFIED
QUESTIONS AND CORRECT SOLUTIONS|
GUARANTEED VALUE PACK| ACE YOUR GRADES.
In design-by-contract, the code responsible for making sure the precondition
(requires clause) is true when a method is called is:
A. the client code that calls the method
B. the code that implements the method
C. both the client and the implementation code
D. neither the client nor the implementation code - (answers)A
Consider the following method signature and, below it, a call to it:
private static int examScore (int studentNumber) {...}
int k = examScore(42);
A. cause the program to crash when it is executed (i.e., it's a run time error)
B. assign an exam score of 42 to student k
,2|Page
C. be legal in Java (though flagged by CheckStyle)
D. be illegal in Java (i.e., it's a compile-time error) - (answers)C
Which statement is true of testing?
A. Testing can prove the correctness of software.
B. Testing can show the presence of defects.
C. Testing can show the absence of defects.
D. If you test a method once for a given input, and it produces correct results,
then the method body is correct for that input. - (answers)B
Which parameter mode is the default for contracts used in this course?
A. Clears
B. Replaces
C. Restores
D. Updates - (answers)C
, 3|Page
Which parameter mode means the outgoing value, in fact the entire behavior of
the method, is independent of the incoming value of that parameter?
A. Clears
B. Replaces
C. Restores
D. Updates - (answers)B
Assume n in an int variable. Which Java expression is true exactly when n is an
odd number, i.e., not divisible by 2, and should be used to check for this
situation?
A. n % 2 == 1
B. n % 2 != 1
C. n % 2 == 0
D. n % 2 != 0 - (answers)D
A type is "primitive type" if:
A. It is illegal to copy a reference to that type, so there can be no aliasing.
B. Variables of that type cannot be passed to any method.
OSU CSE 2221 MIDTERM 2 STUDY GUIDE 2025|
BRAND NEW ACTUAL EXAM WITH 100% VERIFIED
QUESTIONS AND CORRECT SOLUTIONS|
GUARANTEED VALUE PACK| ACE YOUR GRADES.
In design-by-contract, the code responsible for making sure the precondition
(requires clause) is true when a method is called is:
A. the client code that calls the method
B. the code that implements the method
C. both the client and the implementation code
D. neither the client nor the implementation code - (answers)A
Consider the following method signature and, below it, a call to it:
private static int examScore (int studentNumber) {...}
int k = examScore(42);
A. cause the program to crash when it is executed (i.e., it's a run time error)
B. assign an exam score of 42 to student k
,2|Page
C. be legal in Java (though flagged by CheckStyle)
D. be illegal in Java (i.e., it's a compile-time error) - (answers)C
Which statement is true of testing?
A. Testing can prove the correctness of software.
B. Testing can show the presence of defects.
C. Testing can show the absence of defects.
D. If you test a method once for a given input, and it produces correct results,
then the method body is correct for that input. - (answers)B
Which parameter mode is the default for contracts used in this course?
A. Clears
B. Replaces
C. Restores
D. Updates - (answers)C
, 3|Page
Which parameter mode means the outgoing value, in fact the entire behavior of
the method, is independent of the incoming value of that parameter?
A. Clears
B. Replaces
C. Restores
D. Updates - (answers)B
Assume n in an int variable. Which Java expression is true exactly when n is an
odd number, i.e., not divisible by 2, and should be used to check for this
situation?
A. n % 2 == 1
B. n % 2 != 1
C. n % 2 == 0
D. n % 2 != 0 - (answers)D
A type is "primitive type" if:
A. It is illegal to copy a reference to that type, so there can be no aliasing.
B. Variables of that type cannot be passed to any method.