




已阅读5页,还剩31页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
QUESTION 121 Given: Which code, inserted at line 15, creates an instance of the Point class defined in Line? A. Point p = new Point(); B. Line.Point p = new Line.point(); C. The Point class cannot be instatiated at line 15. D. Line 1 = new Line() ; 1.Point p = new 1.Point();Answer: ( B )静态内部类创建方法 非静态内部类的构造:Line.Point p = new Line().new Point();参考大纲:面向对象 内部静态类QUESTION 122 Given: Which statement is true? A. The code will compile without changes. B. The code will compile if public Tree() Plant(); is added to the Tree class. C. The code will compile if public Plant() Tree(); is added to the Plant class. D. The code will compile if public Plant() this(fern); is added to the Plant class. E. The code will compile if public Plant() Plant(fern); is added to the Plant class.Answer: ( D )子类默认调用父类无参构造函数,而Plant没有无参构造函数,因此须显示调用有参构造函数参考大纲:面向对象QUESTION 123 Given: Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.) A. foreach( x ) System.out.print1n(z); B. for( int z : x ) System.out.print1n(z); C. while( x.hashNext() ) System.out.print1n( x.next() ) D. for( int i=0; i x.length; i+ ) System.out.println(xi); Answer: ( B, D )可变参数方法编译后变成数组参数方法,然后利用循环结构取出数组的值参考大纲:流程控制和可变长度参数QUESTION 124 Exhibit: Which statement is true about the classes and interfaces in the exhibit? A. Compilation will succeed for all classes and interfaces. B. Compilation of class C will fail because of an error in line 2. C. Compilation of class C will fail because of an error in line 6. D. Compilation of class AImpl will fail because of an error in line 2.Answer: ( C )参考大纲:面向对象 复写QUESTION 125 Place the lines in the correct order to complete the enum。enum Element Answer: ( )enum Element EARTH, WIND, FIREpublic String info()return “Hot”;public String info()return “element”;列举的内容之后要加上“;”参考大纲:面向对象 enumQUESTION 126Place the code elements in order so that the resulting Java source file will compile correctly, resulting in a class called com.sun.cert.AddressBook.Answer: ( )package com.sum.cert;import java.util.*;public class AddressBookArrayList entries;参考大纲:面向对象 语法基础QUESTION 127 Which two classes correctly implement both the java.lang.Runnable and the java.lang.Clonable interfaces? (Choose two.) A. public class Session implements Runnable, Clonable public void run (); public Object clone(); B. public class Session extends Runnable, Clonable public void run() /*do something*/ public Object clone() /*make a copy*/ C. public class Session implements Runnable, Clonable public void run() /*do something*/ public Object clone() /*make a copy*/ D. public abstract class Session implements Runnable, Clonable public void run() /*do something*/ public Object clone() /*make a copy*/ E. public class Session implements Runnable, implements Clonable public void run() /*do something*/ public Object clone() /*make a copy*/ Answer: ( C, D )A 错误 Session是具体类,方法必须实现B 实现interface用implementsC 正确 D 正确E 错误implements只能出现一次参考大纲:多线程QUESTION 128 Given: Which statement is true? A. 420 is the output B. An exception is thrown at runtime. C. All constructors must be declared public. D. Constructors CANNOT use the private modifier. E. Constructors CANNOT use the protected modifier.Answer: ( A )参考大纲:面向对象QUESTION 129Given: What is the result? A. foofoofoofoofoo B. foobarfoobarbar C. foobarfoofoofoo D. foobarfoobarfoo E. barbarbarbarbar F. foofoofoobarbar G. foofoofoobarfooAnswer: ( D )参考大纲:面向对象属性的重载和遮蔽,该题中子类遮蔽了父类的属性QUESTION 130Which two statements are true about has-a and is-a relationships? (Choose two.) A. Inheritance represents an is-a relationship. B. Inheritance represents an has-a relationship. C. Interfaces must be use when creating a has-a relationship. D. Instance variables can be used when creating a has-a relationship.Answer: ( A, D )参考大纲:面向对象QUESTION 131 -Given: Which statement is true about the class of an object that can reference the variable base? A. It can be any class. B. No class has access to base. C. The class must belong to the geometry package. D. The class must be a subclass of the class Hypotenuse.Answer: ( C )参考大纲:面向对象QUESTION 132 Given:Place the names A and B in the following output.Answer: ( )参考大纲:面向对象 class B has name AQUESTION 133Given: What is the result? A. Compilation fails because of an error in line 3. B. Compilation fails because of an error in line 7. C. Compilation fails because of an error in line 9. D. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in line 5. E. If you define D e = (D)(new E(), then e.bMethod() invokes the version of bMethod()defined in line 5. F. If you define D e = (D)(new E(), then e.bMethod() invokes the version of bMethod() defined in line 9.Answer: ( F ) E类的对象调用b.Method(),因为E类体里有这个方法就遮蔽了父类的方法参考大纲:面向对象QUESTION 134Which two statements are true? (Choose two.) A. An encapsulation, public class promotes re-use. B. Classes that share the same interface are always tightly encapsulated. C. An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods. D. An encapsulated class allows programmer to change an implementation without affecting outside code.Answer: ( A, D)参考大纲:面向对象QUESTION 135 -BTPlace the Relations on their corresponding Implementation Structures. Note: Not all Implementation Structres will be used.Answer: ( )参考大纲:面向对象QUESTION 136Given: And: What is the result? A. Hello B. Hello World C. Compilation fails. D. Hello World 5 E. The code runs with no output. F. An exception is thrown at runtime.Answer: ( C )19行应改为this(),应该放在第一行;参考大纲:面向对象QUESTION 137 -Given: Which two, independently, will allow Sub to compile? (Choose two.) A. Change line 2 to: public int a; B. Change line 2 to: protected int a; C. Change line 13 to: public Sub() this(5); D. Change line 13 to: public Sub() super(5); E. Change line 13 to: public Sub() super(a);Answer: ( C, D )参考大纲:面向对象QUESTION 138 -Given: What is the result when the programmer attempts to compile the code and run it with the command: java Converter 12 ? A. It is true that j = i. B. It is false that j = i. C. An exception is thrown at runtime. D. Compilation fails because of an error in line 13.Answer: ( D )参考大纲:语言基础QUESTION 139Given: What is the output? A. 42 B. 420 C. 462 D. 42042 E. Compilation fails F. An exception is thrown at runtime.Answer: ( D )参考大纲:语言基础QUESTION 140 - BTAssuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given:What is the result? A. Compilation fails B. 1 restored 42 C. 12 restored 42 D. 121 restored 42 E. 1212 restored 42 F. An exception is thrown at runtimeAnswer: ( D )因为父类Food未实现serializable接口,反序列化时将调用Food的构造函数.见工程执行结果参考大纲:IO操作 序列化机制QUESTION 141Given: What is the result? A. a b c B. 1 2 3 C. a1b2c3 D. a1 b2 c3 E. Compilation fails F. The code runs with no output. G. An exception is thrown at runtime. Answer: ( A )参考大纲:实用APIQUESTION 142Given: What is the result? A. Compilation fails B. After line 15, the value of age is 5. C. After line 15, the value of age is 3. D. An exception is thrown at runtime.Answer: ( D )抛出java.util.InputMismatchException异常正确读取方法:scaner.next();scaner.nextInt();scaner.nextBoolean();scaner.nextInt();参考大纲:实用API Scanner简易I/O工具QUESTION 143Given a valid DateFormat object named df, and What updates ds value with the date represented by ds? A. A B. B C. C D. DAnswer: ( C )DateFormat类的parse(String s) 会抛ParseException异常.参考大纲:实用API DataFormatQUESTION 144Place the Fragments into the program, so that the program will get lines from a text file, display them, and then close all the resources.Answer: ( )参考大纲:IO操作QUESTION 145Given: And: Which changes can you make to Target without affecting Client? A. Line 4 of class Target can be changed to return i+; B. Line 2 of class Target can be changed to private int i =1; C. Line 3 of class Target can be changed to private int addOne() D. Line 2 of class Target can be changed to private Integer i = 0;Answer: ( D )A: return +i; 和return i+; 不一样.参考大纲:实用APIQUESTION 146Given: Which statement is true? A. Compilation will succeed if A extends B. B. Compilation will succeed if B extends A. C. Compilation will always fail because of an error in line7. D. Compilation will always fail because of an error in line8.Answer: ( B )参考大纲:面向对象 重写QUESTION 147Given: What is the result? A. Compilation fails. B. Cannot add Toppings C. The code runs with no output. D. A NullPointerException is thrown in Line 4. Answer: ( A )final方法不能重写参考大纲:面向对象QUESTION 148Insert six modifiers into the code such that it meets all of these requirements:Answer: ( )2,4,8,9行符合条件一; 3行符合条件二; 5行符合条件三.参考大纲:语言基础 存取权限QUESTION 149Given: And: What is the result? A. The code runs with no output. B. An exception is thrown at runtime. C. Compilation fails because of an error in line 20. D. Compilation fails because of an error in line 21. E. Compilation fails because of an error in line 23. F. Compilation fails because of an error in line 25.Answer: ( F )a 对象没有y( )方法参考大纲:面向对象QUESTION 150A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways: Which declaration satisfies this requirement? A. public void logIt(String * msgs) B. public void logIt(String msgs) C. public void logIt(String. msgs) D. public void logIt(String msg1, String msg2, String msg3)Answer: ( C )参考大纲:面向对象 可变参数QUESTION 151-Exhibit: What is the result? A. 4321 B. 0000 C. An exception is thrown at runtime. D. Compilation fails because of an error in line 18. Answer: ( D )父类没有无参构造函数参考大纲:面向对象QUESTION 152Given: Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE? A. for( Color c : Color.values() ) B. for( Color c= RED; c=BLUE; c+) C. for( Color c ; c.hasNext() ; c.next() D. for( Color c : Color0; c =Color2; c+) E. for( Color c : Color0; c setAncohor(10,10); s-draw(); E. Shape s =new Circle(); s.Shape.setAnchor(10,10); s.shape.draw();Answer: ( C )参考大纲:面向对象QUESTION 157Given: Which class correctly uses the Data interface and Info class? A. public class Employee extends Info implements Data public void load() /*do something*/ B. public class Employee implements Info extends Data public void load() /*do something*/ C. public class Employee extends Info implements Data public void load() /*do something*/ public void Info.load()/*do something*/ D. public class Employee implements Info extends Data public void Data.load() /*do something*/ public void load()/*do something*/ E. public class Employee implements Info extends Data public void load() /*do something*/ public void Info.load()/*do something*/ F. public class Employee extends Info implements Data public void Data.load() /*do something*/ public void Info.load()/*do something*/ Answer: ( A )参考大纲:面向对象QUESTION 158Which two code fragments correctly create and initialize a static array of int elements? (Choose two.) A. static final int a = 100,200 ; B.static final int a; static a=new int2; a0=100; a1=200; C. static final int a = new int2 100,200 ; -2D. static final int a; static void init() a=new int3; a0= 100; a 1=200; Answer: ( A, B )参考大纲:语言基础 数组QUESTION 159A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command: java -classpath /test games.Chess Bobs CLASSPATH is set (at login time) to: /usr/lib:/home/bob/classes:/opt/java/lib: What is a possible location for the Chess.class file? A. /test/Chess.class B. /home/bob/Chess.class C. /test/games/Chess.class D. /usr/lib/games/Chess.class E. /home/bob/games/Chess.class F. Inside jarfile /opt/java/lib/Games.jar (with a correct manifest) G. Inside jarfile /home/bob/downloads/Games.jar (with a correct manifest) Answer: ( C )参考大纲:语言基础QUESTION 160Given: What is the result? A. s 14 B. s 16 C. s 10 D. Compilation fails E. An exception is thrown at runtime.Answer: ( D )第19行错误,接口中定义的方法都是抽象公共的,变量都是常量。所以在实现接口的时候方法的修饰符都必须是公共的。参考大纲:面向对象QUESTION 161Given: What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The variable first is set to null. D. The variable first is set to elements0. Answer: ( D )参考大纲:语言基础QUESTION 162Given: And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to . (current directory). Which two java commands entered at the command line will run MainClass? (Choose two.) A. java MainClass if run from the /apps directory B. java pany.application.MainClass if run from the /apps directory C. java -classpath /apps pany.application.MainClass if run from any directory D. java -classpath . Mainclass if run from the /apps/com/company/application directory E. java -classpath /apps/com/company/application:. MainClass if run from the /apps directory F. java pany.application.MainClass if run from the /apps/com/company/application directory Answer: ( B, C )参考大纲:语言基础QUESTION 163Given: What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The attribute id in the Item object remains unchanged. D. The attribute id in the Item object is modified to the new value. E. A new Item object is created with the preferred value in the id attribute.Answer: ( A )参考大纲:面向对象 final修饰符QUESTION 164A programmer has an algorithm(算法) that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access. What supports these requirements? A. java.util.Queue B. java.util.ArrayList C. java.util.LinearList D. java.util.LinkedList Answer: ( D )参考大纲:集合要求高效的插入元素,但是不要求支持快速访问. 链表支持快速增删元素,但是访问比较慢QUESTION 165Which two statements are true about the hashCode method? (Choose two.) A. The hashCode method for a given class can be used to test for object equality and object inequality for that class. B. The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set. C. The hashCode method for a given class can be used to test for object inequality, but NOT object equality for that class. D. The only important characteristic of the values returned by a hashCode method is that the distribution of valus must follow a Gaussian distribution. E. The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval. Answer: ( C、E )HashCode表示对象的物理地址. Java建议规则:1如果两对象equals()为真,则hashCode()必须要一样. 2若两对象hashCode()不一样,两对象equals()一定不为真. 3若hashCode()一样,两对象equals()不一定返回真.给不同的对象不同的hashCode可以提hash table的效率.A:hashCode可以保证两对象是否相同.错误, hashCode相同的对象不一定相同. 见第一建议B:hashCode是用来给SortedSet集合做排序的.错! 应该是compareTO(Object o)C: hashCode是可以保证两对象是否不同,但是不能保证两对象是否相同. hashCode不同的对象,equals一定为假. 见第二条建议.D:hashCode方法必须遵循高斯分布算法. 错, hashCode方法没有实现高斯分布算法.E:set集合的元素存放是依据hashCode来
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030空调行业市场发展现状及竞争格局与投资价值研究报告
- 2025-2030磨砂玻璃行业风险投资发展分析及投资融资策略研究报告
- 2025-2030眼镜行业风险投资发展分析及投资融资策略研究报告
- 2025-2030盐酸多西环素注射液行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030电镀锌薄板(EZC)行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2025-2030电动汽车产业市场发展分析及发展趋势与投资研究报告
- 2025-2030独立式雾化器行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030牙髓供应行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030渔船行业市场发展分析及发展趋势前景预测报告
- 2025-2030混合动力SUV行业市场现状供需分析及投资评估规划分析研究报告
- 地理课题的研究与演讲模板
- DB11T 1888-2021 海绵城市雨水控制与利用工程施工及验收标准
- 腰椎间盘突出症课件(共100张课件)
- A、B封灌胶来料检验标准
- 西安丝路智慧-智慧文旅云服务平台建设方案
- 2025年4月自考00504艺术概论押题及答案
- 第九届全国大学生测井技能大赛备赛试题库-中(多选题)
- 公交驾驶员心理素质培训考核试卷
- 【安踏体育跨国并购亚玛芬体育的财务绩效探究12000字(论文)】
- 二下音乐《阿西里西(简谱、五线谱)》公开课课件
- 土方工程转让合同范本2024年
评论
0/150
提交评论