iZhirO

Inheritance

Dec 4th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. class Parent{
  2.     int x = 5;
  3. }
  4.  
  5. class Child extends Parent{
  6.     int x = 10;
  7.    
  8.     public void Info(int x){
  9.         System.out.println("Nilai X sebagai parameter = " + x);
  10.         System.out.println("Data member X di class Child = " + this.x);
  11.         System.out.println("Data member X di class Parent = " + super.x);
  12.     }
  13. }
  14.  
  15. public class Tes_Super {
  16.     public static void main(String args[]){
  17.         Child tes = new Child();
  18.         tes.Info(20);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment