Created
June 20, 2019 04:18
-
-
Save hadihammurabi/d5c5cca8671147e7b883ba1867eb148e to your computer and use it in GitHub Desktop.
Example for Interface and Abstrac Class in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Makhluk { | |
abstract void berjalan(); | |
void tidur() { | |
System.out.println("Kucing sedang tidur"); | |
} | |
} | |
interface Hewan { | |
void makan(); | |
} | |
class Kucing extends Makhluk implements Hewan { | |
@Override | |
void berjalan() { | |
System.out.println("Kucing sedang berjalan"); | |
} | |
@Override | |
public void makan() { | |
System.out.println("Kucing sedang makan"); | |
} | |
} | |
public class InterAbs { | |
public static void main(String[] args) { | |
Kucing miaw = new Kucing(); | |
miaw.berjalan(); | |
miaw.makan(); | |
miaw.tidur(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment