Advertisement
BlackBoY_

yg abstract

Jul 1st, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ContohAbstractInterface;
  2.  
  3. public abstract class AbstraksiAnjay {
  4.     public abstract void berubah();
  5.     public void bergabung(){
  6.         System.out.println("Menjadi Robot Raksasa");
  7.     }
  8. }
  9.  
  10. class rangerMerah extends AbstraksiAnjay{
  11.  
  12.     @Override
  13.     public void berubah() {
  14.         System.out.println("Berubah Ranger Merah");
  15.     }
  16. }
  17.  
  18. class rangerHijau extends AbstraksiAnjay{
  19.  
  20.     @Override
  21.     public void berubah() {
  22.         System.out.println("Berubah Rangers Hijau");
  23.     }
  24. }
  25.  
  26. class exekusi{
  27.     public static void main(String[] args) {
  28.         AbstraksiAnjay red = new rangerMerah();
  29.         AbstraksiAnjay green = new rangerHijau();
  30.         red.berubah();red.bergabung();
  31.         green.berubah();green.bergabung();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement