document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class Parent {
  2.     int x = 5;
  3.     public void Info(){
  4.         System.out.println("Ini class Parent");
  5.     }
  6. }
  7.  
  8. Buat class dengan nama Child
  9. public class Child extends Parent {
  10.  
  11.     int x = 10;
  12.  
  13.     public void Info() {
  14.         System.out.println("Ini class Child");
  15.     }
  16. }
  17.  
  18. Buat class dengan nama Tes
  19. public class Tes {
  20.  
  21.     public static void main(String[] args) {
  22.         Parent tes = new Child();
  23.         System.out.println("Nilai x=" + tes.x);
  24.         tes.Info();
  25.     }
  26. }
');