CSE 2221 Final UPDATED ACTUAL QUESTIONS WITH
CORRECT ANSWERS
Question 1.
The Implements Relation
ANSWER
The implements relation may hold between a class and an interface. If C implements I then
class C contains code for the behavior specified in interface I. This means that C has method
bodies for instance methods whose contracts are specified in I.
The code of C looks like this:
class C implements I {
// bodies for methods specified in I
}
The implements relation allows you to separate contracts from their implementations- a best
practice for component design.
Question 2.
The Extends Relation
ANSWER
The extends relation may hold between: 2 interfaces or 2 classes.
If B extends A then B inherits all the methods of A. This means B implicitly starts out with all
the method contracts (for an interface) or all the method bodies (for a class) that A has. B can
then add more method contracts (for an interface) or method bodies (for a class).
Question 3.
Overloading
ANSWER
A method (name) is overloaded when 2 or more methods have the same name, in which case
methods must differ in the number and/or types of their formal parameters (which the
compiler uses to disambiguate them)
,Question 4.
Interface Extension
ANSWER
If I1 and I2 are interfaces and I2 extends I1, then the code of I2 looks like this: interface I2
extends I1{
//contracts for methods added in I2
}
For interfaces all such methods are instance.
Question 5.
Testing
ANSWER
Testing is a technique for trying to refute the claim that a method body is correct for the
method contract. In other words, the goal of testing is to show that the method body does not
correctly implement the contract i.e. that it is defective
Question 6.
Tree Representation of Expression
ANSWER
Each operand (1,2,3,4,5,..) of an operator (+ - * /) must be evaluated before that operator can
be evaluated
Question 7.
Unit Testing
ANSWER
Best practice to test individual units of components of software (one class, one method at a
time)
Question 8.
Integration Testing
ANSWER
Testing what happens when multiple components are put together into a larger system
, Question 9.
System testing
ANSWER
testing a whole end-user system
Question 10.
Method Correctness
ANSWER
Look at method's contract, which is a specification of its intended behaviors. The actual
behaviors of the method (see body) must be within the allowed behaviors of the method (see
contract).
Question 11.
Test Plan/Fixture
ANSWER
A set of test cases for a given unit is called a test plan or a test fixture for that unit
Question 12.
Designing a test plan
ANSWER
To make testing most likely to succeed in revealing defects, best practices include: (1) Test
boundary cases: smallest, largest, and special values in the contract (2) test routine cases (3)
test challenging cases, ie ones that if you were writing the code, you might find difficult or
error prone
Question 13.
Test cases
ANSWER
Each input value and corresponding allowed/expected result is a test case. Test cases that do
not reveal a defect in the code do not help us to refute a claim of correctness. Test cases
exercises a single unit of code, normally a method. Test cases should be small and
independent of each other.
CORRECT ANSWERS
Question 1.
The Implements Relation
ANSWER
The implements relation may hold between a class and an interface. If C implements I then
class C contains code for the behavior specified in interface I. This means that C has method
bodies for instance methods whose contracts are specified in I.
The code of C looks like this:
class C implements I {
// bodies for methods specified in I
}
The implements relation allows you to separate contracts from their implementations- a best
practice for component design.
Question 2.
The Extends Relation
ANSWER
The extends relation may hold between: 2 interfaces or 2 classes.
If B extends A then B inherits all the methods of A. This means B implicitly starts out with all
the method contracts (for an interface) or all the method bodies (for a class) that A has. B can
then add more method contracts (for an interface) or method bodies (for a class).
Question 3.
Overloading
ANSWER
A method (name) is overloaded when 2 or more methods have the same name, in which case
methods must differ in the number and/or types of their formal parameters (which the
compiler uses to disambiguate them)
,Question 4.
Interface Extension
ANSWER
If I1 and I2 are interfaces and I2 extends I1, then the code of I2 looks like this: interface I2
extends I1{
//contracts for methods added in I2
}
For interfaces all such methods are instance.
Question 5.
Testing
ANSWER
Testing is a technique for trying to refute the claim that a method body is correct for the
method contract. In other words, the goal of testing is to show that the method body does not
correctly implement the contract i.e. that it is defective
Question 6.
Tree Representation of Expression
ANSWER
Each operand (1,2,3,4,5,..) of an operator (+ - * /) must be evaluated before that operator can
be evaluated
Question 7.
Unit Testing
ANSWER
Best practice to test individual units of components of software (one class, one method at a
time)
Question 8.
Integration Testing
ANSWER
Testing what happens when multiple components are put together into a larger system
, Question 9.
System testing
ANSWER
testing a whole end-user system
Question 10.
Method Correctness
ANSWER
Look at method's contract, which is a specification of its intended behaviors. The actual
behaviors of the method (see body) must be within the allowed behaviors of the method (see
contract).
Question 11.
Test Plan/Fixture
ANSWER
A set of test cases for a given unit is called a test plan or a test fixture for that unit
Question 12.
Designing a test plan
ANSWER
To make testing most likely to succeed in revealing defects, best practices include: (1) Test
boundary cases: smallest, largest, and special values in the contract (2) test routine cases (3)
test challenging cases, ie ones that if you were writing the code, you might find difficult or
error prone
Question 13.
Test cases
ANSWER
Each input value and corresponding allowed/expected result is a test case. Test cases that do
not reveal a defect in the code do not help us to refute a claim of correctness. Test cases
exercises a single unit of code, normally a method. Test cases should be small and
independent of each other.