COMPLETE SOLUTIONS AND VERIFIED
ANSWERS GRADED A+
⩥ 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).
⩥ 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)
⩥ 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.
,⩥ 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
⩥ Tree Representation of Expression. Answer: Each operand
(1,2,3,4,5,..) of an operator (+ - * /) must be evaluated before that
operator can be evaluated
⩥ Unit Testing. Answer: Best practice to test individual units of
components of software (one class, one method at a time)
⩥ Integration Testing. Answer: Testing what happens when multiple
components are put together into a larger system
⩥ System testing. Answer: testing a whole end-user system
⩥ 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).
⩥ 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
, ⩥ 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
⩥ 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.
⩥ Replaces Mode. Answer: Upon return from a method call, a replaces-
mode parameter has a value that might be changed from its incoming
value, but the method's behavior does not depend on its incoming value.
A replaces-mode parameter, e.g., x should not appear in the requires
clause, and #x should not appear in the ensures clause
⩥ Declared/Static Type. Answer: When a variable is declared using the
name of an interface as its type, e.g. NN k = new NN2(); then its
declared/static type is said to be an interface type (here declared type is
NN). Best practice to declare vars this way.
When a variable is declared using the name of a class as its type, e.g.
NN2 k = new NN2() then its declared type (or static type) is said to be a
class type.here declared type is NN2)