Bapa

Untitled

Mar 17th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. class Base
  2. {
  3. int i = 99;
  4.  
  5.   public void amethod()
  6.   {
  7.          System.out.println("Base.amethod()");
  8.       }
  9.       Base()
  10.   {
  11.         amethod();
  12.       }
  13. }
  14.  
  15. public class Derived extends Base
  16. {
  17. int i = -1;
  18.        
  19. public static void main(String argv[])
  20. {
  21.         Base b = new Derived();
  22.          System.out.println(b.i);
  23.          b.amethod();
  24.       }
  25.  
  26.       public void amethod()
  27.   {
  28.          System.out.println("Derived.amethod()");
  29.       }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment