




已阅读5页,还剩31页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1.How many bytes of storage are required for an integer of type long in Java? (b)(a) Four(b) Eight(c) Two(d) Three 注:java中有8种基本类型:byte:8位无符号整数 short: 16位有符号整数 int:32位有符号整数 long:64(8字节)位有符号整数 float:32位单精度浮点数double:64位单精度浮点数 char:单个字符,使用16位Unicode编码 boolean2. The two Boolean literals available in Java are _ and _. (d)(a) T, F(b) 0, 1(c) TRUE, FALSE(d) true, false 3. Consider the following line of Java code. (c) int x = 1+7*2; What will be the value of x at the end of execution of the line of code? (a) 21(b) 16(c) 15(d) 9 4. How many lines of output will be produced by the following code fragment? (d)for (int i = 0; i 4; +i) for (int j = 1; j 3 ; +j) stdOut.println(i + j);(a) 10(b) 12(c) 6(d) 8 5. Which is the Java keyword used to denote a class method? (d)(a) class(b) private(c) final(d) static 6 ?According to Javadoc convention, the first sentence of each Javadoc comment should be (c)(a) an author tag(b) the order of lines is not important(c) a summary sentence of the declared entry(d) an version tag7. The coding system used to represent characters in Java is (c)(a) bytecode(b) ASCII(c) Unicode(d) EBCDIC 8. Which expression below evaluates to true if and only if x is in the range 0, 9 (inclusive)? (a)(a) !(x 9)(b) 0 x 9(c) 0 = 9(d) x 0 & x 9 9. Which of the following is a valid integer constant declaration? (a)(a) final int SCALE = 10;(b) int final SCALE = 10;(c) final SCALE = 10;(d) int SCALE = 10; 10. Which of the following is a valid character literal in Java?(注意字符与字符串的表示) (a)(a) ;(b) (c) a(d) = 11. ?Which of the following is not equivalent in value to the following expression? (b) flag = false(a) flag != true(b) flag(c) !flag(d) !(flag = true) 12. Which of the following statements is used to exit from a switch statement? (a)(a) break;(b) end;(c) exit;(d) default; 13. Which of the following is not a legal identifier in Java? (c)(a) first_index(b) $first_index(c) 1index(d) index1 14. In Java, what is the identifier for the primitive type used to represent a character? (b)(a) Character(b) char(c) character(d) Char 15. Which of the following is a valid literal of type float in Java? (c)(a) 10.5sp(b) 10.5fp(c) 10.5f(d) 10.5d 16. Which of the following statements about constructors in Java is true? (a)(a) A class can define more than one constructor.(b) A class must define at least one constructor.(c) A constructor must be defined as public.(d) A constructor must be defined as static. . 17.According to the document entitled Code Conventions for the Java Programming Language, file suffixes used by Java software include which of the following? (b)I. .obj II. .class III. .h (a) I and II only(b) II only(c) II and III only(d) I and III only 18. A stack trace is (c)(a) a list of variables allocated on a programs stack(b) a fatal error that causes a typical debugger to terminate(c) a sequence of method calls(d) only available through a typical debuggers step into feature 注:堆栈轨迹:如果你需要打印出某个时间的调用堆栈状态,你将产生一个堆栈轨迹。stack trace 中包括三部分,分别为:.bss .text .databss: 表示程序中未初始化的全局变量的一块内存区域text: 表示程序中已初始化的全局变量的一块内存区域data:表示存放程序执行代码的一块内存区域19.Which method must exist in every Java application? (a) begin(b) paint(c) init(d) main Correct answer is (d)20.A Java identifier may begin with all but which of the following? (a) $(b) if(c) _ (the underscore)(d) 0 Correct answer is (d)21.In the context of Java programming, garbage collection refers to (a) automatic balancing of parenthesis performed by some editors(b) removal of Java programs that could cause damage to a system(c) conversion of comments into Javadoc comments(d) automatic return of memory to the heap for objects no longer required by the program Correct answer is (d)22.What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x+y);(a) 5+2(b) 5 2(c) 7(d) 52 Correct answer is (c)23. Which of the following parts of an if-else-statement is optional? (a) the if part(b) the else part(c) the parenthesis around the condition(d) the condition Correct answer is (b)24.Which of the following is the Java loop construct typically used when the range is clear? (a) while-loop(b) for-loop(c) switch-loop(d) do-while-loop Correct answer is (b)25.Consider the following Java program segment.import java.io.*;public class Test public Test( ) System.out.println(default); public Test( int i ) System.out.println(non-default); public static void main(String args) Test t = new Test(2); Which of the following will be output during execution of the program segment?(a) The line of text non-default followed by the line of text default(b) The line of text default followed by the line of text non-default(c) The line of text default(d) The line of text non-default Correct answer is (d)26.What is the name of the JDK program that processes Javadoc comments? (a) java(b) javac(c) javacom(d) javadoc Correct answer is (d)27.According to the Java code conventions, files longer than _ lines should be _.(a) 100, encouraged(b) 100, avoided(c) 2000, avoided(d) 2000, encouraged Correct answer is (c)28.The primitive floating-point types available in Java are _ and _. (a) real, double(b) float , double(c) real , float(d) single , real Correct answer is (b)29.How many bytes are required to represent a Unicode(统一的字符编码标准,采用双字节) character? (a) Four(b) One(c) Three(d) Two Correct answer is (d)30.How many lines of output will be produced by the following code fragment?for (int i = 0; i 3; +i) for (int j = 0; j i; +j) stdOut.println(i + j); (a) 6(b) 4(c) 3(d) 5 Correct answer is (c)31.Which of the following statements about class variables in Java is not true??(a) Class variables require the modifier static in the declarations.(b) All objects have their own copy of the class variable defined in the instantiated class.(c) Non-static methods in a class can access the class variable defined in the same class.(d) Class variables do not need the reference to the object of the instantiated class to access them. Correct answer is (b)32.The term class variable is a synonym for (a) an instance variable(b) a read-only variable(c) a private data field(d) a static data field Correct answer is (d)33.Which of the following patterns of characters opens a Javadoc comment block? (a) /*(b) /(c) /*(d) */ Correct answer is (a)34.The term wrapper classes refers to (a) the Java classes that contain at least two data fields(b) the Java classes that contain themselves(c) a collection of Java classes that wrap Java primitive types(d) a collection of Java classes that contain other Java classesCorrect answer is (c)35.Given the following code, what value will be output by the last statement?StringTokenizer st = new StringTokenizer(this is,a,test of tokens, ,);String s;int count = 0;while (st.hasMoreTokens() s = st.nextToken(); +count;stdOut.println(count);(a) 3(b) 1(c) 6(d) 4Correct answer is (a)注:好像是根据逗号划分36.Consider the following Java program x = 5;int y = 2;System.out.println(x + 1 + y);Which of the following statements is true about the program segment?(a) The output caused by the code will be 512.(b) The output caused by the code will be 8.(c) The code will cause a compilation error.(d) The output caused by the code will be 5 1 2.Correct answer is (a)37.Consider the following Java program segment.?import java.io.*;public class SomeClass public void x() throw new RuntimeException(Exception from x); public void y() throw new IOException(Exception from y); Which of the following is true concerning the definitions for the methods x and y?(a) Neither x nor y has a legal definition.(b) Both x and y have legal definitions.(c) x has a legal definition, but y has an illegal definition.(d) x has an illegal definition, but y has a legal definition.Correct answer is (c)38.In Java, exceptions that are not handled are passed up the?(a) exception ladder(b) call stack(c) catch blocks(d) block hierarchyCorrect answer is (b)39.After a typical debugger encounters a breakpoint, the programmer using the debugger may perform which of the following actions?1. Examine the values of variables in the halted program2. Execute the current line(当前行)3. Resume(重新开始) execution of the halted(停止) program(a) III only(b) I, II, and III(c) I only(d) I and II onlyCorrect answer is (b)40.The name of a Java source file (a) must use the extension .class(b) must be the same as the class it defines, respecting case(c) must be the same as the class it defines, ignoring case(d) has no restrictionsCorrect answer is (b)41.A difference between the methods print and println of the class java.io.PrintWriter is that(a) println appends a new line to the end of its output, but print does not(b) print appends a new line to the end of its output, but println does not(c) println inserts a new line at the beginning of its output, but print does not(d) print inserts a new line at the beginning of its output, but println does notCorrect answer is (a)42.What is the right way to handle abnormalities(异常) in input on Java? (a) By handling these problems by providing exception handlers(b) By always specifying the throws clause in every method header where file I/O is performed(c) By using the class FileFilter which gracefully filters out bad input data(d) By writing while loops to guard against bad inputCorrect answer is (a)43.All Java exception classes are derived from the class(a) java.lang.RuntimeException(b) java.lang.Throwable(c) java.lang.Error(d) java.io.IOExceptionCorrect answer is (b)44.Which of the following statements is true of the conventions outlined by Sun Microsystems in the document entitled Code Conventions for the Java Programming Language?I. They define a standard interface definition language that must be used for all Java classes.II. They provide recommendations intended to make source code easier to read and understand.III. They describe one mechanism for network communication between Java and C+ programs.(a) III only(b) I, II, and III(c) II only(d) I and III onlyCorrect answer is (c)45.A tool that allows programmers to execute lines of a program one line at a time in order to help locate the source of a programs errors is known as a(n)(a) debugger(b) stack trace(c) exception handler(d) scopeCorrect answer is (a)46.Which of the following is not true concerning objects and their representation? (a) objects are represented by their addresses(b) objects are represented by value(c) objects are represented by reference(d) objects are represented indirectly Correct answer is (b)47.In programming, a loop is generally used to achieve (a) branching(b) succession(c) repetition(d) selection Correct answer is (c)48.If a class contains a constructor, that constructor will be invoked (a) each time an object of that class goes out of scope(b) once at the beginning of any program that uses that class(c) once the first time an object of that class is instantiated(d) each time an object of that class is instantiated Correct answer is (d)49.Which of the following categorizations can be applied to both the data fields and the methods in a Java class?(a) native and non-native(b) static and non-static(c) default and non-default(d) abstract and non-abstract Correct answer is (b)50. According to the Java code conventions, files that contain Java source code have the suffix _, and compiled bytecode files have the suffix _.(a) .javac, .class(b) .java, .class(c) .class, .javac(d) .class, .java Correct answer is (b)51.Variables of primitive types are also referred to as ?(a) references(b) classes(c) objects(d) scalars (标量)Correct answer is (d)52.Based on the following declaration, what does b1 represent just after the declaration is executed?Button b1;(a) a default Button object(b) a Button object with no label(c) a blank Button object(d) nothing Correct answer is (d)53. The return type for a method that returns nothing to its caller is (a) not specified in the method definition(b) false(c) null(d) void Correct answer is (d)54.What is the name of the wrapper class for the type int? (a) Integer(b) INT(c) integer(d) Int Correct answer is (a)55. Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? I It does not incur run-time overhead(开支). II It can be used to import multiple packages with a single statement. III It can be used to import multiple classes with a single statement.(a) III only(b) I and III only(c) I only(d) I, II, and III Correct answer is (b)56. What will be output caused by the execution of the following Java program segment?String name = Elvis;System.out.print(name + was here);(a) Elviswas here(b) name was here(c) Elvis was here(d) name + was here Correct answer is (a)57. As an aid in debugging a program in Java, print statements may be used to display which of the following types of information?The names of methods being called The values of the parameters of a method The values of the instance variables of a class (a) I and II only(b) I, II, and III(c) II and III only(d) I and III only Correct answer is (b)58. Which package does not need to be explicitly imported into a Java program? (a) java.applet(b) java.awt(c) java.io(d) java.lang Correct answer is (d)59.UML class diagrams can describe which of the following?I The internal structure of classesII Relationships between classes(a) None(b) II only(c) I and II(d) I onlyCorrect answer is (c) 60.In a UML class diagrams representation of a class, the top, middle, and lower rectangular compartments respectively describe the _ of the class.(a) name, methods, and constants(b) name, attributes, and methods(c) attributes, methods, and name(d) attributes, methods, and constantsCorrect answer is (b)61.Consider the following Java program segment.String str = Three,Two,One;for (int i = 0; i str.length; +i)System.out.println(stri+/);What will be output upon execution of the program segment?(a) Three/Two/One/(b) One/Two/Three/(c) One,Two,Three(d) Three,Two,OneCorrect answer is (a)62.Regarding the following declaration, what is the index of the element containing 45?intnumbers = -1, 45, 6, 132;(a) 45(b) 1(c) 2(d) 0Correct answer is(b)63.If the length of a particular array is the value of LIMIT, what is the index of the last item in that array?(a) LIMIT(b) LIMIT / 2(c) LIMIT - 1(d) 0Correct answer is(c)64.A Java array that contains n components will be indexed from _ through _.(a) 1, n-1(b) 0, n-1(c) 1, n(d) 0, nCorrect answer is(b)65.Legal Java statements to initialize an array reference include which of the following?I. int aobj = 0, 1, 2;II. int4 aobj = 0, 1, 2;III. int aobj = new int3;(a) I only(b) I and II only(c) III only(d) I and III onlyCorrect answer is(d)66.The class java.util.ArrayList implements a collection that(a) can only store primitive variables such as int or boolean(b) can grow to accommodate new items(c) cannot be accessed using an integer index(d) can only store instances of the class java.lang.StringCorrect answer is(b)67.In which of the following ways can items be added to a collection implemented by java.util.ArrayList?1. Items can be inserted at the beginning of the collection.2. Items can be inserted between two existing items in the collection.3. Items can be appended to the end of the collection.(a) III only(b) I and III only(c) I only(d) I, II, and IIICorrect answer is(d)68.An object that contains methods that traverse a collection linearly from start to finish is known as a(n)(a) Exception(b) int(c) loop(d) iteratorCorrect answer is(d)69.Which of the following statements is not true of the class java.util.ArrayList?(a) The constructor of the ArrayList class, when called with no arguments, causes an empty ArrayList to be constructed.(b) An instance of ArrayList can grow to accommodate new items when the collection is full.(c) Once an object is inserted into an instance of ArrayList, it can never be removed.(d) Items stored by an instance of ArrayList can be accessed using integer indexes.Correct an
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 谢在库管员授课课件
- 2025年度特许经营合同纠纷诉讼担保书样本
- 2025常年知识产权纠纷预防与应对顾问合同
- 2025版智慧城市基础设施设计合同
- 2025版全新水钻工程设计与施工监理合同范本下载
- 2025版离婚夫妻债务明确划分及财产分割协议
- 2025年度高层建筑外墙抹灰施工与维护一体化合同范本
- 2025年汽车租赁与二手车交易服务合同范本
- 2025国外工作合同协议书
- 2025劳动局劳动合同模板
- GB/T 9634.8-2018铁氧体磁心表面缺陷极限导则第8部分:PQ型磁心
- GB/T 19355.1-2016锌覆盖层钢铁结构防腐蚀的指南和建议第1部分:设计与防腐蚀的基本原则
- GB/T 18358-2001中小学教科书幅面尺寸及版面通用标准
- 《计算机网络(第5版)》英文版教学课件
- 特种设备使用安全管理讲解课件
- 外科学课件-肺癌
- 中移全通系统集成业务能力简介
- 梁若瑜著-十二宫六七二象书增注版
- 苏教版数学六年级上册《全册课件》教学精品ppt
- 数控机床概述课件
- 电路板维修培训教材PPT模板
评论
0/150
提交评论