CSE 2221 Final: CSE 2221 Object-Oriented Programming Notes
Document Summary
The implements relation may hold between a class and an interface. Incidentally, and unfortunately, only instance methods not static methods, can be specified in. The extends relation may hold between: two interfaces (as on the earlier slide), or, two classes. Caveats about java interfaces (cid:862)if b e(cid:454)te(cid:374)ds a the(cid:374) b i(cid:374)herits all the (cid:373)ethods of a(cid:863) So there is no good place to write separate contracts for the constructors of classes that implement an interface. So there is no good place to write separate contracts for public static methods of classes that implement an interface: constructors are not inherited. So in the situation above, the class b must include bodies for any constructors that are expected, even if they would be identical to those of a. The bodies of the constructors in b generally would simply invoke the constructors of a, (cid:449)hi(cid:272)h is do(cid:374)e usi(cid:374)g the spe(cid:272)ial (cid:374)otatio(cid:374) super(cid:894) (cid:895)