本帖最后由 董将 于 2012-12-22 19:39 编辑
1、class Super
{
int i=0;
public Super(String a)
{
System.out.println("A");
i=1;
}
public Super()
{
System.out.println("B");
i=4;
}
}
class Demo extends Super
{
public Demo(String a)
{
System.out.println("C");
i=5;
}
public static void main(String[] args)
{
Super d=new Demo("A");
System.out.println(d.i);
}
}
2.
class Super
{
int i=0;
public Super(String a)
{
System.out.println("A");
i=1;
}
public Super()
{
System.out.println("B");
i=4;
}
}
class Demo extends Super
{
int i=2;
public Demo(String a)
{
System.out.println("C");
i=5;
}
public static void main(String[] args)
{
Super d=new Demo("A");
System.out.println(d.i);
}
}
3
class Super
{
int i=0;
public Super(String a)
{
System.out.println("A");
i=1;
}
public Super()
{
System.out.println("B");
i=4;
}
}
class Demo extends Super
{
int i=7;
public Demo(String a)
{ super(a);
System.out.println("C");
i=5;
}
public static void main(String[] args)
{
Super d=new Demo("A");
System.out.println(d.i);
}
|