java选择题题库.doc_第1页
java选择题题库.doc_第2页
java选择题题库.doc_第3页
java选择题题库.doc_第4页
java选择题题库.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

窗体顶端2.Which of the following is a valid character literal in Java? (a) ; (b) = (c) (d) aCorrect answer :A窗体底端2.A Java identifier may begin with all but which of the following? (a) $(b) if(c) _ (the underscore)(d) 0 Correct answer is (d)3.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)9.What is the name of the JDK program that processes Javadoc comments? (a) java(b) javac(c) javacom(d) javadoc Correct answer is (d)2.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)3.How many bytes are required to represent a Unicode character? (a) Four(b) One(c) Three(d) Two Correct answer is (d)5.How many lines of output will be produced by the following code fragment? for (int i = 0; i 4; +i) for (int j = 1; j 3 ; +j) stdOut.println(i + j);(a) 12(b) 6(c) 10(d) 8 Correct answer is (d)6.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) 7.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)8.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)9.Which of the following patterns of characters opens a Javadoc comment block? (a) /*(b) /(c) /*(d) */ Correct answer is (a)2.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)3.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)7.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)10.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 line3. 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)6.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)7.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)9.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?1. They define a standard interface definition language that must be used for all Java classes.2. They provide recommendations intended to make source code easier to read and understand.3. 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)10.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)2.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)5.In programming, a loop is generally used to achieve (a) branching(b) succession(c) repetition(d) selection Correct answer is (c)7.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)8.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)10. 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)2.Variables of primitive types are also referred to as (a) references(b) classes(c) objects(d) scalars Correct answer is (d)3.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)8. 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)2.What is the name of the wrapper class for the type int? (a) Integer(b) INT(c) integer(d) Int Correct answer is (a)3. Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? It does not incur run-time overhead. It can be used to import multiple packages with a single statement. 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)4. 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)10. 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

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论