单选题
Java
2019-03-04
下列程序的运行结果是( )。

A.Shape
A.Shape
B.Circle
B.Circle
C.ShapeCircle
C.ShapeCircle
D.程序有错误
D.程序有错误
参考答案
C
答案解析
继承是面向对象编程的一个主要优点之一,它对如何设计 Java 类有着直接的影响。该程序首先编写了一个 Shape 的类,然后又编写一个类 Circle 去继承 Shape 类。由于子类拥有父类所有的属性和方法,所以输出的是 ShapeCircle。
你可能感兴趣的试题
A.class Manager extends Employee{
public int getSalary(double x){}
}
public int getSalary(double x){}
}
A.class Manager extends Employee{
public int getSalary(double x){}
}
public int getSalary(double x){}
}
B.class Manager extends Employee{
public double getSalary (int x, int y){}
}
public double getSalary (int x, int y){}
}
B.class Manager extends Employee{
public double getSalary (int x, int y){}
}
public double getSalary (int x, int y){}
}
C.class Manager extends Employee{
public double getSalary(){}
}
public double getSalary(){}
}
C.class Manager extends Employee{
public double getSalary(){}
}
public double getSalary(){}
}
D.class Manager extends Employee{
public int getSalary(int x,int y){}
}
public int getSalary(int x,int y){}
}
D.class Manager extends Employee{
public int getSalary(int x,int y){}
}
public int getSalary(int x,int y){}
}
A.protected
A.protected
B.public
B.public
C.private
C.private
D.缺省
D.缺省
A.输出 exception
A.输出 exception
B.输出 test. dat
B.输出 test. dat
C.输出 IOException
C.输出 IOException
D.无显示
D.无显示
