日期:2014-05-20  浏览次数:20718 次

动态联编
class   A  
{
void   fun1()
{
System.out.println( "A.fun1 ");
}
void   fun2()
{
System.out.println( "A.fun2 ");
}
}

class   B   extends   A
{
void   fun2()
{
System.out.println( "B.fun2 ");
}
public   void   showBThis()
{
this.fun1();
this.fun2();
}
public   void   showBSuper()
{
super.fun1();
super.fun2();   /*   Call   A.fun2,   why   not   B.fun2?   */
}
}

public   class   C   extends   B
{
void   fun1()
{
System.out.println( "C.fun1 ");
}
public   static   void   main(String[]   args)
{
C   c   =   new   C();
System.out.println( "c.showBThis() ");
c.showBThis();
System.out.println( "c.showBSuper() ");
c.showBSuper();
}
}

------解决方案--------------------
C.fun1
B.fun2

A.fun1
B.fun2
------解决方案--------------------
supper写在B里面,当然是B的supper