Invoke1.java

   1	 class Invoke1 {
   2	     public static void main(String argv[]) {
   3		 B bb = new B();
   4		 bb.m();
   5		 A aa = (A)bb;
   6		 aa.m();         //the output of this and previous 2 statements 
   7	     }                   //are the same!!!
   8	 }
   9
  10	 abstract class A {
  11	     String e = "Ae";
  12	     String f = "Af";
  13	     void a() {
  14		 System.out.println("Aa");
  15	     }
  16	     void b() {
  17		 System.out.println("Ab");
  18	     }
  19	     abstract void d();
  20	     void m() {
  21		 a();
  22		 b();
  23		 //c(); compiler arror
  24		 d();
  25		 System.out.println(e);
  26		 System.out.println(f);
  27		 //System.out.println(g); compiler error
  28	     }
  29	 }
  30
  31	 class B extends A {
  32	     String e = "Be";
  33	     String g = "Bg";
  34	     void a() {
  35		 System.out.println("Ba");
  36	     }
  37	     void c() {
  38		 System.out.println("Bc");
  39	     }
  40	     void d() {
  41		 System.out.println("Bd");
  42	     }
  43	     void m() {
  44		 a();                                            //Ba
  45		 b();                                            //Ab
  46		 c();                                            //Bc
  47		 d();                                            //Bd
  48		 System.out.println(e);                          //Be
  49		 System.out.println(f);                          //Af
  50		 System.out.println(g);                          //Bg
  51		 super.a();                                      //Aa
  52		 super.b();                                      //Ab
  53		 //super.c(); compiler error
  54		 //super.d(); compiler error
  55		 System.out.println(super.e);                    //Ae
  56		 System.out.println(super.f);                    //Af
  57		 //System.out.println(super.g); compiler error
  58		 super.m();                          //Ba Ab Bd Ae Af
  59	     }
  60	 }
  61
  62