欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

    【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc

    • 资源ID:1336862       资源大小:99.50KB        全文页数:15页
    • 资源格式: DOC        下载积分:5000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要5000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc

    1、计算机 Java认证-理解类继承、理解多态和类型转换及答案解析(总分:84.96,做题时间:90 分钟)一、B不定项选择题/B(总题数:2,分数:85.00)Refer to this class for the following two questions.public class Account private int money;public int getMoney() return this.money;public void setMoney(int money) this.money = money;(分数:48.96)(1).In the code segment, what

    2、 is the method getMoney() considered? A. Get method B. Access method C. Getter method D. Instance Variable method(分数:3.06)A.B.C.D.(2).In the code segment, what is the method setMoney (int money) considered? A. Set method B. Access method C. Setter method D. Instance variable method(分数:3.06)A.B.C.D.(

    3、3).Which of the following defines information hiding? A. Information hiding is hiding as much detail about your class as possible so others cant steal it. B. Information hiding is about hiding implementation details and protecting variables from being used the wrong way. C. Information hiding is use

    4、d to obscure the interworking of your class so external classes must use the public interface.(分数:3.06)A.B.C.D.(4).What access modifier is used to make the instance variable or method available only to the class in which it is defined? A. public B. private C. protected D. package-private (default)(分

    5、数:3.06)A.B.C.D.(5).What access modifier is used for methods that were defined in an interface? A. public B. private C. protected D. package-private (default)(分数:3.06)A.B.C.D.(6).What is the proper signature for class X if it inherits class Z? A. public class X inherits Z. B. public class X extends Z

    6、. C. public class X implements Z.(分数:3.06)A.B.C.D.(7).How many classes can a class extend directly? A. Zero B. One C. Two D. As many as it needs(分数:3.06)A.B.C.D.(8).How many interfaces can a class implement directly? A. Zero B. One C. Two D. As many as it needs(分数:3.06)A.B.C.D.(9).Consider the follo

    7、wing UML illustration for assistance with this question: What is the proper signature for class A if it implements interfaces B and C?(分数:3.06)A.B.C.D.(10).Consider the following UML illustration for assistance with this question: What is the proper signature for interface I to inherit interfaces J

    8、and K?(分数:3.06)A.B.C.D.(11).Which statement is true about the term polymorphism? A. It is a Latin word that roughly means “changeable.“ B. It is a Greek word that roughly means “many forms.“ C. It is an old English word that roughly means “insectlike.“ D. It is a new technical term that means “Java

    9、object.“(分数:3.06)A.B.C.D.(12).What type of object can polymorphically behave as another? A. An object can act as any subclass of the class it was created from. B. An object can act as any superclass of the class it was created from. C. An object can act as any other abstract class.(分数:3.06)A.B.C.D.(

    10、13).Polymorphism helps to facilitate which of the following? (Choose all that apply.) A. Highly optimized code B. Code reuse C. Code obfuscation D. Code that is genetic and flexible(分数:3.06)A.B.C.D.(14).What is a correct “is-a“ relationship? A. A specific object “is-a“ more generic one. B. A genetic

    11、 object “is-a“ more specific one. C. A null object “is-an“ object.(分数:3.06)A.B.C.D.(15).Which of the following statements explain why an object can polymorphically behave as an interface? A. By implementing the interface, the object is required to have all of the functionality that the interface rep

    12、resents. B. By implementing the interface, the object inherits all the required methods it defines. C. An object can behave as an interface because interfaces do not have a strict expected behavior and therefore any object can act as an interface.(分数:3.06)A.B.C.D.(16).What does it mean if a develope

    13、r is programming to an interface? A. The developer is implementing an interface for the class he or she is working on. B. The developer was given a set of interfaces he or she must implement. C. The developer is defining the functionality instead of strict object types as much as possible.(分数:3.06)A

    14、.B.C.D.The Drivable interface:public interface Drivable /* Drivable definitions*/The Tractor class:public class Tractor implements Drivable /* Tractor functionality*/The Vehicle class:public class Vehicle /* Vehicle functionality*/The Car class:public class Car extends Vehicle implements Drivable /*

    15、 Car functionality*/The Truck class:public class Truck extends Vehicle implements Drivable /* Truck functionality*/(分数:36.00)(1).Given the preceding classes and interface, would the following code segment produce errors when compiled? Car car = new Car(); Vehicle vehicle = car; A. No errors would be

    16、 produced. B. This code would result in compile errors.(分数:4.00)A.B.C.D.(2).Given the preceding classes and interface, would the following code segment produce errors when compiled? Truck truck = new Truck(); Drivable drivable = truck; A. No errors would be produced. B. This code would result in com

    17、pile errors.(分数:4.00)A.B.C.D.(3).Given the preceding classes and interface, would the following code segment produce errors when compiled? Tractor tractor = new Tractor(); Vehicle vehicle = tractor; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A.B.C.D.(4).Give

    18、n the preceding classes and interface, would the following code segment produce errors when compiled? Drivable drivable = new Drivable(); Truck truck = drivable; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A.B.C.D.(5).Given the preceding classes and interface

    19、, would the following code segment produce errors when compiled? Vehicle vehicle = new Vehicle(); Object o = vehicle; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A.B.C.D.(6).Given the preceding classes and interface, would the following code segment produce e

    20、rrors when compiled? Truck truck = new Truck(); Object o = truck; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A.B.C.D.(7).In what cases is casting needed? (Choose all that apply.) A. Going from a superclass to subclass B. Going from a subclass to superclass C

    21、. Using an int as a double D. Using a float as a long(分数:4.00)A.B.C.D.(8).Why must the a variable be casted? A. So future developers understand the intended use of the variable B. To tell the compiler that the data conversion is safe to make C. Because it was used polymorphically before(分数:4.00)A.B.

    22、C.D.(9).What would cause an exception to be thrown from a cast? A. If precision is lost due to the cast B. If the object is cast to a superclass of its current type C. If the object was never instantiated as the object that it is being cast to or one of its subclasses D. If the object is being cast

    23、is null(分数:4.00)A.B.C.D.计算机 Java认证-理解类继承、理解多态和类型转换答案解析(总分:84.96,做题时间:90 分钟)一、B不定项选择题/B(总题数:2,分数:85.00)Refer to this class for the following two questions.public class Account private int money;public int getMoney() return this.money;public void setMoney(int money) this.money = money;(分数:48.96)(1).In

    24、 the code segment, what is the method getMoney() considered? A. Get method B. Access method C. Getter method D. Instance Variable method(分数:3.06)A.B.C. D.解析:这是一个 getter方法。getter 方法用于获取一个 private的实例变量。getter 方法的名字总是get后紧跟以大写字母开头的变量名。如果变量是一个 boolean类型,则 get被替代为 is。A、B 和 D都不正确,并且它们不是典型的 Java术语。(2).In t

    25、he code segment, what is the method setMoney (int money) considered? A. Set method B. Access method C. Setter method D. Instance variable method(分数:3.06)A.B.C. D.解析:这是一个 setter方法。setter 方法用于设置一个 private的实例变量。setter 方法的名字总是set后紧跟以大写字母开头的变量名。它们需要一个参数并且使用它来设置变量。A、B 和 D都不正确,并且不是典型的 Java术语。(3).Which of t

    26、he following defines information hiding? A. Information hiding is hiding as much detail about your class as possible so others cant steal it. B. Information hiding is about hiding implementation details and protecting variables from being used the wrong way. C. Information hiding is used to obscure

    27、the interworking of your class so external classes must use the public interface.(分数:3.06)A.B. C.D.解析:好的类设计尽可能多地隐藏方法和实例变量。这是通过使用 private访问修饰符来完成的。这就是为什么外部对象不要试图以开发者不期望的方式与对象进行交互。隐藏信息使得代码更易于维护和更模块化。A 和 C不正确。A 不正确,因为信息隐藏与代码保护没有关系。C 不正确,因为访问修饰符应该用于强制外部类使用合适的公共接口。(4).What access modifier is used to make

    28、 the instance variable or method available only to the class in which it is defined? A. public B. private C. protected D. package-private (default)(分数:3.06)A.B. C.D.解析:private 访问修饰符用于只允许类中的方法访问方法或者实例变量。A、C 和 D不正确。A 不正确,因为 public将使实例变量对所有类都可见。C 不正确,因为 protected将使实例变量对所有子类或者同一包中的任何类都可见。D 不正确,因为包私有的或者默

    29、认的访问级别,将使实例变量对同一包中的任何其他类可见。(5).What access modifier is used for methods that were defined in an interface? A. public B. private C. protected D. package-private (default)(分数:3.06)A. B.C.D.解析:当实现接口的方法时,使用 public访问修饰符。B、C 和 D不正确。因为它们限制了方法的可访问性,因此不适合于一个接口。(6).What is the proper signature for class X if

    30、it inherits class Z? A. public class X inherits Z. B. public class X extends Z. C. public class X implements Z.(分数:3.06)A.B. C.D.解析:extends 关键字用于继承一个类。A 和 C不正确。A 不正确,因为 inherits不是有效的 Java关键字。C 不正确,因为 implements关键字用于接口,而不是类。(7).How many classes can a class extend directly? A. Zero B. One C. Two D. As

    31、 many as it needs(分数:3.06)A.B. C.D.解析:一个类只能扩展一个其他类。但是,它可以使一个类扩展一个又扩展了另一个类的类,以此类推。A、C 和 D不正确。(8).How many interfaces can a class implement directly? A. Zero B. One C. Two D. As many as it needs(分数:3.06)A.B.C.D. 解析:类可以按需实现多个接口。A、B 和 C不正确。(9).Consider the following UML illustration for assistance with

    32、this question: What is the proper signature for class A if it implements interfaces B and C?(分数:3.06)A.B. C.D.解析:类使用关键字 implements来实现一个接口。要实现多个接口,则接口应该出现在关键字implements后以逗号分隔的列表中。A、C、D 和 E不正确。A 不正确,因为 implements关键字不应该被包括多次。C 不正确,因为应该使用 implements关键字而不是 interface,并且它只应该使用一次。D 不正确,因为应该使用 implements而不是

    33、interface。E 不正确,因为 extends用于类,而不是接口;应该使用 implements替代。(10).Consider the following UML illustration for assistance with this question: What is the proper signature for interface I to inherit interfaces J and K?(分数:3.06)A. B.C.D.解析:接口也可以继承其他接口。不同于类,接口可以按照需要继承或者扩展多个接口。接口使用关键字extends,紧跟逗号分隔的一个列表,列出该接口希望

    34、扩展的所有其他接口。B、C 和 D不正确。B 不正确,因为只有类实现接口。一个接口扩展其他接口。C 不正确,因为应该使用 extends,并且只能用一次。D不正确,因为没有正确使用 interface关键字。(11).Which statement is true about the term polymorphism? A. It is a Latin word that roughly means “changeable.“ B. It is a Greek word that roughly means “many forms.“ C. It is an old English word

    35、 that roughly means “insectlike.“ D. It is a new technical term that means “Java object.“(分数:3.06)A.B. C.D.解析:多态这个单词来源于希腊语,意思为“多种形式”。A、C 和 D不正确。(12).What type of object can polymorphically behave as another? A. An object can act as any subclass of the class it was created from. B. An object can act

    36、as any superclass of the class it was created from. C. An object can act as any other abstract class.(分数:3.06)A.B. C.D.解析:对象继承了其超类的所有功能,因此可以多态地具有它们的行为。A 和 C不正确。A 不正确,因为对象不能用作其子类,因为子类更具体并且包含父类中不存在的功能。C 不正确,因为这些类之间需要有“is-a”关系。这个答案没有提及是什么关系。(13).Polymorphism helps to facilitate which of the following?

    37、(Choose all that apply.) A. Highly optimized code B. Code reuse C. Code obfuscation D. Code that is genetic and flexible(分数:3.06)A.B. C.D. 解析:多态有助于创建可重用的代码,因为它允许代码可以编写得更抽象,因此 B正确。类似于 B,通过使用任何更具体对象都可以满足的通用数据类型,多态使得代码更通用。因此,D 也正确。A 和 C不正确。A不正确,因为多态对代码优化方面没有影响。C 不正确,因为混淆代码(目的是让代码难以阅读)与多态无关。(14).What is

    38、 a correct “is-a“ relationship? A. A specific object “is-a“ more generic one. B. A genetic object “is-a“ more specific one. C. A null object “is-an“ object.(分数:3.06)A. B.C.D.解析:一个更具体的对象可以被看成是一个更通用的对象。这是多态的基本原则。B 和 C不正确。B 不正确,因为通用对象不具有更具体对象的所有功能,因此与具体的对象不具备“is-a”关系。C 不正确,因为一个 null对象对它与其他对象间的关系没有影响。(1

    39、5).Which of the following statements explain why an object can polymorphically behave as an interface? A. By implementing the interface, the object is required to have all of the functionality that the interface represents. B. By implementing the interface, the object inherits all the required metho

    40、ds it defines. C. An object can behave as an interface because interfaces do not have a strict expected behavior and therefore any object can act as an interface.(分数:3.06)A. B.C.D.解析:当类实现一个接口时,它需要实现接口包含的所有方法。这给予类在接口中定义的功能。因此允许该类用作接口。B 和 C不正确。B 不正确,因为当接口被实现时,没有继承任何东西。C 不正确,因为每一个接口都有严格的行为预期。这由必须实现的方法来

    41、表示。(16).What does it mean if a developer is programming to an interface? A. The developer is implementing an interface for the class he or she is working on. B. The developer was given a set of interfaces he or she must implement. C. The developer is defining the functionality instead of strict obje

    42、ct types as much as possible.(分数:3.06)A.B.C. D.解析:面向接口编程意味着开发者定义功能来代替对象数据类型。然后任何对象都可以实现所需要的接口,并使用它。如果不使用接口,则只能使用定义的特定的数据类型对象。A 和 B不正确。A 不正确,因为面向接口编程与只在类中实现接口相比是一个更大的概念。B 不正确,因为在这种情形下,开发者只是实现了预先确定的一组接口。The Drivable interface:public interface Drivable /* Drivable definitions*/The Tractor class:public

    43、class Tractor implements Drivable /* Tractor functionality*/The Vehicle class:public class Vehicle /* Vehicle functionality*/The Car class:public class Car extends Vehicle implements Drivable /* Car functionality*/The Truck class:public class Truck extends Vehicle implements Drivable /* Truck functi

    44、onality*/(分数:36.00)(1).Given the preceding classes and interface, would the following code segment produce errors when compiled? Car car = new Car(); Vehicle vehicle = car; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A. B.C.D.解析:不会产生错误,因为 Car类扩展了 Vehicle类,因此可

    45、以用作一个 Vehicle对象。B 不正确。(2).Given the preceding classes and interface, would the following code segment produce errors when compiled? Truck truck = new Truck(); Drivable drivable = truck; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A. B.C.D.解析:不会产生错误,因为 Truck类实

    46、现了 Drivable接口,因此可以用作一个 Drivable对象。B 不正确。(3).Given the preceding classes and interface, would the following code segment produce errors when compiled? Tractor tractor = new Tractor(); Vehicle vehicle = tractor; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A.B.

    47、C.D.解析:这段代码将会导致编译错误,因为 Vehicle类不是 Tractor类的超类。A 不正确。(4).Given the preceding classes and interface, would the following code segment produce errors when compiled? Drivable drivable = new Drivable(); Truck truck = drivable; A. No errors would be produced. B. This code would result in compile errors.(分

    48、数:4.00)A.B. C.D.解析:这段代码会导致编译错误,因为 Drivable是一个接口,它不能被实例化。A 不正确。(5).Given the preceding classes and interface, would the following code segment produce errors when compiled? Vehicle vehicle = new Vehicle(); Object o = vehicle; A. No errors would be produced. B. This code would result in compile errors.(分数:4.00)A. B.C.D.解析:不会产生错误,因为 Vehicle类不是具体类,并且 Object类是每个 Java对象的超类。B 不正确。(6).Given the preceding classes and interface, would the following code segment produce errors when compiled? Truck truck = new Truck(); Object o = truck; A. No errors would be produced. B. This code would re


    注意事项

    本文(【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc)为本站会员(王申宇)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1 

    收起
    展开