class SuperClass
{
int x;
SuperClass()
{
x=3;
System.out.print("in SuperClass:x"+x);
}
void doSomething()
{
System.out.print("in SuperClass.doSomething()");
}
}
class SubClass extends SuperClass
{
int x;
SubClass()
{
super();
x=5;
System.out.print("in SubClass:x="+x);
}
void doSomething()
{
super.doSomething();
System.out.print("in SubClass.doSomething()");
System.out.print("super.x="+super.x+"sub.x="+x);
public class inheritance
{
public static void main(String[]args)
{
SubClass subC=new SubClass();
subC.doSomething();
}
}
我的油箱是wade9900@yahoo.com.cn
谢谢你们的帮忙!谢谢啊!
ai0909 于 2011-10-21 16:12:33发表:
路过。。。
wade9900 于 2005-05-17 21:26:22发表:
经过自己认真的调试跟检查!终于得到答案了啊!谢谢各位啊!
class SuperClass
{
int x;
SuperClass()
{
x=3;
System.out.print("in SuperClass:x="+x);
}
void doSomething()
{
System.out.print("in SuperClass.doSomething()");
}
}
class SubClass extends SuperClass
{
int x;
SubClass()
{
super();
x=5;
System.out.print("in SubClass:x="+x);
}
void doSomething()
{
super.doSomething();
System.out.print("in SubClass.doSomething()");
System.out.print("super.x="+super.x+"sub.x="+x);
}
}
public class inheritance
{
public static void main(String[]args)
{
SubClass subC=new SubClass();
subC.doSomething();
}
}