Sunday 17 March 2013

SCJP - 14 -Select the two statements that best indicate a situation with low coupling. (Choose two.)


14. Select the two statements that best indicate a situation with low coupling. (Choose two.)

A. The attributes of the class are all private.
B. The class refers to a small number of other objects.
C. The object contains only a small number of variables.
D. The object is referred to using an anonymous variable, not directly.
E. The reference variable is declared for an interface type, not a class. The interface provides a
small number of methods.
F. It is unlikely that changes made to one class will require any changes in another.

Answer:

E and F are correct. Only having access to a small number of methods implies limited
coupling. If the access is via a reference of interface type, it may be argued that there is
even less opportunity for coupling as the class type itself is not visible. Stating that changes
in one part of a program are unlikely to cause consequences in another part is really the
essence of low coupling. There is no such thing as an anonymous variable. Referring to
only a small number of other objects might imply low coupling, but if each object has many
methods, and all are used, then coupling is high. Variables (attributes) in a class should
usually be private, but this describes encapsulation, rather than low coupling. Of course,
good encapsulation tends to reduce coupling as a consequence.

A, B, C and D are incorrect based on the preceding treatise.
(Objective 5.1)

No comments:

Post a Comment