//在控制台输出继承的a变量的值 和 子类b变量的值
public void show(){
( 3 ) (提示:使用父类的方法)
System.out.println("b="+b);
System.out.println(super().a)这样吗
如有帮助,望采纳
父类创建变量的get方法,
子类在类中创建自己的对象,调用get方法获得父类参数
父类
public class Father {
int a=1;
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
}
子类
public class Son extends Father {
int b=7;
public static void main(String[] args) {
Son son=new Son();
System.out.println(son.getA());
System.out.println(son.b);
}
}