Advertisement
andari3107

abstraction

Dec 4th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. abstract class hewan{
  2.     abstract void makan();
  3. }
  4.  
  5. class kucing extends hewan{
  6.     void makan() {
  7.         System.out.println("Kucing makan ikan");
  8.     }
  9. }
  10.  
  11. class tikus extends hewan{
  12.     void makan() {
  13.         System.out.println("Tikus makan kue");
  14.     }
  15. }
  16.  
  17. class abstraction{
  18.     public static void main(String args[]) {
  19.         hewan h;
  20.         h = new kucing();
  21.         h.makan();
  22.         h = new tikus();
  23.         h.makan();
  24.        
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement