好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

第七章继承多态练习题(共10页).doc

10页
  • 卖家[上传人]:文库****9
  • 文档编号:211183012
  • 上传时间:2021-11-16
  • 文档格式:DOC
  • 文档大小:227KB
  • / 10 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 精选优质文档-----倾情为你奉上第七章继承多态一、选择题:1、分析: class A { A() { } } class B extends A { //系统自动生成的构造方法和类的访问权限一样 } 哪两种说法是正确的? ( )A:类B的构造方法是public的. B:类B的构造方法包含对this()的调用.C:类B的构造方法没有参数. D:类B的构造方法包含对super()的调用.2、运行结果是:( ) class Base { Base() { System.out.print("Base"); } } public class Alpha extends Base { public static void main( String[] args ) { new Alpha(); new Base(); } } A: Base B: BaseBase C: 编译失败. D: 没有输出. E: 运行时异常.3. 程序的运行结果是?( )A: 编译失败. B: hello from a C: hello from bD: hello from b E: hello from ahello from a hello from b4. 运行结果是:( ) class TestSuper { TestSuper(int i) { } } class TestSub extends TestSuper{ } class TestAll { public static void main (String [] args) { new TestSub(); } }A: 编译失败. B: 程序运行没有异常.C: 第7行抛出异常. D: 第2行抛出异常.5. 程序的运行结果是?( )A: 0 B: 1 C: 2 D: 编译失败.6. 对于语句"B is a D" 和 "B has a C",一下哪两种说法是正确的? ( )A:D是B. B:B是D. C:D是C. D:B是C. E:D继承 B. F:B 继承D.7. 运行结果是?( )A: 1 B: 2 C: 第8行编译失败. D: 第14行编译失败.8. 分析: public class ConstOver { public ConstOver(int x, int y, int z) { } } 哪两个是对ConstOver 的构造方法的重载? ( )A:ConstOver() { } B:protected int ConstOver() { }C:private ConstOver(int z, int y, byte x) { }D:public Object ConstOver(int x, int y, int z) { }E:public void ConstOver(byte x, byte y, byte z) { }9. 运行结果是?( )A: 4,4 B: 4,5 C: 5,4 D: 5,5 E: 编译失败.10. 分析: public class X { public X aMethod() { return this;} } 1) public class Y extends X { 2) 3) } 在第2行可以插入哪两项? ( )A:public void aMethod() { } B:private void aMethod() { }C:public void aMethod(String s) { } D:private Y aMethod() { return null; }E:public X aMethod() { return new Y(); }11. 运行结果是?( )A: 4,4 B: 4,5 C: 5,4 D: 5,5 E: 编译失败.12. 以下哪两个重载了方法setVar()? ( ) public class MethodOver { public void setVar(int a, int b, float c) { } } A:private void setVar(int a, float c, int b) { } B:public int setVar(int a, float c, int b) {return a;}C:protected void setVar(int a, int b, float c) { } D:public int setVar(int a, int b, float c) {return a;}E:protected float setVar(int a, int b, float c) {return c;}13. 分析: 1) class BaseClass { 2) private float x = 1.0f; 3) protected void setVar(float f) { x = f; } 4) } 5) class SubClass extends BaseClass { 6) private float x = 2.0f; 7) // insert code here 8) } 在第7行插入哪两个覆盖了方法setVar()? ( )A:void setVar(float f) { x = f; } B:public void setVar(int f) { x = f; }C:public void setVar(float f) { x = f; } D:public double setVar(float f) { return f; }E:public final void setVar(float f) { x = f; } F:protected float setVar() { x = 3.0f; return 3.0f; }14. 运行结果是?( )A: 1 B: 2 C: 运行时异常. D: 第8行编译错误. E: 第14行编译错误.15. 分析: class A { protected int method1(int a, int b) { return 0; } } 在A的子类中,以下哪两个方法是合法的? ( )A:public int method1(int a, int b) { return 0; } B:private int method1(int a, long b) { return 0; }C:private int method1(int a, int b) { return 0; } D:public short method1(int a, int b) { return 0; }E:static protected int method1(int a, int b) { return 0; }16. 分析: 1) public abstract class Test { 2) public abstract void methodA(); 3) 4) public abstract void methodB()5) { 6) System.out.println("Hello"); 7) } 8) }哪两种改法,可以使程序通过编译? ( )A:给方法methodA()加方法体 C:在Test的声明中去掉abstractB:用";"替换第5-7行 D:在方法methodA()的声明中去掉abstractE: 在方法methodB()的声明中去掉abstract17. 运行结果是:( ) 1) abstract class AbstractIt { 2) abstract float getFloat(); 3) } 4) public class AbstractTest extends AbstractIt { 5) private float f1 = 1.0f; 6) private float getFloat() { return f1; } 7) } A: 编译成功. B: 运行时异常. C: 第2行编译失败. D: 第6行编译失败.18. 在接口中哪两个方法的声明是合法的? ( )A:void method1(); B:public void method2(); C:static public void method5();D:protected void method3(); E:final public void method4();19. 分析: 1) public interface Foo { 2) int k = 4; 3) } 哪三项与第2行等价? ( )A:final int k = 4; B:public int k = 4; C:static int k = 4;D:abstract int k = 4; E:volatile int k = 4; F:protected int k = 4;20. 分析: interface Inter { } class A implements Inter { } class B extends A { B() { A[] arr = new A[10]; boolean b1 = this instanceof Inter; boolean b2 = arr instanceof Object; System.out.println("b1 = " + b1 + ", b2 = " + b2); } } 创建B的对象时会输出?( )A: 编译失败. B: b1 = true, b2 = true C: b1 = true, b2 = falseD: b1 = false, b2 = true E: b1 = false, b2 = false21. 哪一个能通过编译?( )A: new Animal().soundOff(); B: Lion l = Alpha1.get("meat eater");C: Elephant e = new Alpha1(); D: new Alpha1().get("veggie").soundOff();22. 分析: class Passenger { } class Engine { } interface TransportVehicle { void loadPassengers(); } interface Helicopter extends Tran。

      点击阅读更多内容
      相关文档
      2025年大唐华北电力试验研究院内蒙分部(呼和浩特)招聘笔试高频考点题库考试试题.docx 2025年黑龙江齐齐哈尔克山县嘉暖热电有限公司招聘公笔试高频考点题库考试试题【含答案】.docx 2025年配电安规通用部分(重点人员)模拟(100题)【含答案】.docx 2025年“才聚齐鲁成就未来”山东省国控建筑材料工业设计笔试高频考点题库考试试题【含答案】.docx 2025年贵州汇智达人力资源服务有限公司招聘笔试高频考点题库考试试题【含答案】.docx 2025年“才聚齐鲁成就未来”山东黄金集团井下技能工人招笔试高频考点题库考试试题【含答案】.docx 2025年重庆市合川瑞山中学教师招聘考试笔试试题【含答案】.docx 2025年行政执法资格认证通用法律知识考试复习题【含答案】.docx 2025年辅警考试模拟试题(100题)【含答案】.docx 2025年安徽铜陵县枞阳县供销投资有限公司招聘工作人员笔试考试试题【含答案】.docx 2025年重庆市辅警考试模拟试题(100题)【含答案】.docx 2025年重庆市大足区国衡商贸股份有限公司招聘劳务派遣制笔试高频考点题库考试试题【含答案】.docx 2025年《物业管理师》三级模拟试题(110题)【含答案】.docx 2025年青河县高校毕业生“三支一扶”计划招募考试笔试试题【含答案】.docx 2025年成都市西体路小学校教师招聘考试笔试试题.docx 2025年北京青年政治学院招聘考试笔试试题.docx 2025年成都市青白江区九所学校招聘教师考试笔试试题.docx 2025年成都市海滨小学校教师招聘考试笔试试题.docx 2025年成都市郫都区教育局下属学校招聘教师考试笔试试题.docx 2025年佛山市南海区事业单位招聘考试笔试试题.docx
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.