Friday, December 28, 2012

OCJP Questions - 2

A company that makes Computer Assisted Design (CAD) software has, within its
application, some utility classes that are used to perform 3D rendering tasks. The
company's chief scientist has just improved the performance of one of the utility classes'
key rendering algorithms, and has assigned a programmer to replace the old algorithm
with the new algorithm. When the programmer begins researching the utility classes, she
is happy to discover that the algorithm to be replaced exists in only one class. The
programmer reviews that class's API, and replaces the old algorithm with the new
algorithm, being careful that her changes adhere strictly to the class's API. Once testing
has begun, the programmer discovers that other classes that use the class she changed are
no longer working properly. What design flaw is most likely the cause of these new
A. Inheritance
B. Tight coupling
C. Low cohesion
D. High cohesion
E. Loose coupling

Answer: B


5. class Thingy { Meter m = new Meter(); }
6. class Component { void go() { System.out.print("c"); } }
7. class Meter extends Component { void go() { System.out.print("m"); } }
9. class DeluxeThingy extends Thingy {
10. public static void main(String[] args) {
11. DeluxeThingy dt = new DeluxeThingy();
12. dt.m.go();
13. Thingy t = new DeluxeThingy();
14. t.m.go();
15. }
16. }
Which two are true? (Choose two.)
A. The output is mm.
B. The output is mc.
C. Component is-a Meter.
D. Component has-a Meter.
E. DeluxeThingy is-a Component.
F. DeluxeThingy has-a Component.

Answer: A,F

No comments:

Post a Comment