1 / 8

Pemrograman Berorientasi Objek

Pemrograman Berorientasi Objek. Bab 5 – Package & Interface. Package. A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer.

darius-pope
Download Presentation

Pemrograman Berorientasi Objek

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pemrograman Berorientasi Objek Bab 5 – Package & Interface

  2. Package • A package is a namespace that organizes a set of related classes and interfaces. • Conceptually you can think of packages as being similar to different folders on your computer. • You might keep HTML pages in one folder, images in another, and scripts or applications in yet another.

  3. Purpose • Organization. • Because software written in the programming language can be composed of hundreds or thousands of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages.

  4. Interface • is a class like constructs that only contains constants and abstract methods. • Purpose: define constants and abstract methods (that should be implemented by class) that can be used by several class. • So interface is like contract between class and interface.

  5. Constant and Method in Interface • Each constant in an interface is public static final by default, so we don’t need to write it. • Each method in an interface is public abstract by default.

  6. Interface Rule • Can’t be instantiate. • Can be used as data type. • Implemented not inherited by class. • Can be inherited by other interface. • A class can implement many interfaces not like inheritance (a class only inherits a class). • Each method in interface MUST be implemented by class that implement the interface.

  7. Warning • Since a class can inherit multiple interface, beware of name collision. • Name collision is same name (for constant or method) in different interface but implemented by a class. • Try to avoid it.

  8. How To? • <modifier> interface <Name> {} • Show sample!!

More Related