在子类构造方法的哪个地方可以调用其父类的构造方法
1个回答
展开全部
父类:
package object;
public class FatherClass {
public FatherClass(){
System.out.println("this is fatherClass!!!");
}
}
****************************************
子类:
package object;
public class SunClass extends FatherClass {
public SunClass() {
System.out.println("this is SunClass");
}
public static void main(String[] args) {
SunClass sun=new SunClass();
}
}
直接实例化子类 不重写构造方法就能调用了
package object;
public class FatherClass {
public FatherClass(){
System.out.println("this is fatherClass!!!");
}
}
****************************************
子类:
package object;
public class SunClass extends FatherClass {
public SunClass() {
System.out.println("this is SunClass");
}
public static void main(String[] args) {
SunClass sun=new SunClass();
}
}
直接实例化子类 不重写构造方法就能调用了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询