Download presentation
Presentation is loading. Please wait.
1
Interfaces U Abd. Rohim, MT mailto: info@abdrohim.com
Website/Blog: Interfaces
2
Interface Adalah prototipe untuk kelas (serupa dg kelas abstrak) yg berisi kumpulan data (Konstanta) dan method tanpa implementasi aktual Interface & Class Abstract : serupa tapi tidak sama Interface diimplementasikan oleh sebuah kelas Kelas yg mengimplementasikan interface harus menyediakan semua method yg disebut dalam interface Interface dapat diturunkan dari inteface lainnya Interface dapat diturunkan secara ulti inherintace U Abd. Rohim, Java (Interfaces)
3
Contoh Interface interface Driveable { boolean startEngine( );
void stopEngine( ); float accelerate( float acc ); boolean turn( Direction dir ); } class Automobile implements Driveable { ... public boolean startEngine( ) { if ( notTooCold ) engineRunning = true; } public void stopEngine( ) { engineRunning = false; public float accelerate( float acc ) { public boolean turn( Direction dir ) { U Abd. Rohim, Java (Interfaces)
4
Implementasi Interface
Class Automobile implement Driveable interface Driveable startEngine( ) stopEngine( ) accelerate() turn() interface Driveable startEngine( ) stopEngine( ) accelerate() turn() HonkHorn() Class Lawnmower implement Driveable interface Driveable startEngine( ) stopEngine( ) accelerate() turn() CutGrass() U Abd. Rohim, Java (Interfaces)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.