Advertisement
BlackBoY_

Overridingex

Jun 23rd, 2021
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package tutorial;
  2.  
  3. public class Overridingex {
  4.     public void suarahewan(){
  5.         System.out.println("hewan memiliki suara");
  6.     }
  7. }
  8.  
  9. class Anjing extends Overridingex{
  10.     public void suaraAnjing(){
  11.         System.out.println("Anjing : guk guk guk");
  12.     }
  13. }
  14. class Kucing extends Overridingex{
  15.     public void suaraKucing(){
  16.         System.out.println("Kucing : meow meow meow");
  17.     }
  18. }
  19.  
  20. class main{
  21.     public static void main(String[] args) {
  22.         Anjing dog = new Anjing();
  23.         dog.suaraAnjing();
  24.         Kucing cat = new Kucing();
  25.         cat.suaraKucing();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement