【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc
《【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】计算机Java认证-理解类继承、理解多态和类型转换及答案解析.doc(15页珍藏版)》请在麦多课文档分享上搜索。
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
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 JAVA 认证 理解 继承 类型 转换 答案 解析 DOC
