JAVA练习题含答案 ANSWERS TO PRACTICE 2.
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Multiple Choice
1Which operator is used to concatenate two strings?
(a+
(b–
(c*
(d/
Answer:A(see page35
2Which operator returns the remainder of integer division? (a%
(b/
(c*
(dnone of the above
Answer:A(see page26
3What is the value of the variable c in the statements that follow? String phrase="Make hay while the sun is shining.";
char c=phrase.charAt(10;
(aw
(bh
(ci
(dNone of the above
Answer:B(see page40
4The escape sequence the represents the new-line character is:
(a\r
(b\t
(c\n
(d\\
Answer:C(see page43
5The syntax that declares a Java named constant named SALES_TAX is: (adouble SALES_TAX=7.50;
(bpublic double SALES_TAX=7.50;
(cpublic static double SALES_TAX=7.50;
(dpublic static final double SALES_TAX=7.50;
Answer:D(see page47
6In Java,a block comment is delimited by:
(a*//*
(b/*/*
(c/**/
(d*/*/
Answer:C(see page50
7To mark a block comment for inclusion in the Javadoc documentation,the block must
be delimited by:
(a/***/
(b*/**/
(c**//*
(d**/*/
Answer:A(see page50
8Valid arguments to the System.out ob ject’s println method include:
(a“Anything with double quotes”
(bString variables
(cVariables of type int
(dAll of the above
Answer:D(see page59
9Which statement or group of statements produces the output:Java programming is
fun!
(aSystem.out.print(Java programming;
System.out.print(is fun!;
(bSystem.out.println(Java programming is fun!;
(cSystem.out.println(“Java programming”;
System.out.println(“is fun!”;
(dSystem.out.print(“Java programming”
System.out.println(“is fun!”;
Answer:D(see page60
10If a hyphen is added after the%in a format specifier,the output will be_________. (aLeft justified
(bRight justified
(cCentered
(dNone of the above
Answer:A(see page64
11The statement:System.out.printf("%6.2f",597.7231;displays:
(a597.723
(b597.72
(c000597.72
(dNone of the above
Answer:B(see page64
12The Java method printf is based on the________language.
(aPascal
(bC++
(cC
(dADA
Answer:C(see page67
13The class NumberFormat allows you to specify a constant representing which country’s
currency format should be used.To use this constant you must import:
(ajava.util.Locale
(bjava.util.Currency
(cjava.util.Properties
(dNone of the above.
Answer:A(see page71
14Standard code libraries in Java are called:
(aMethods
(bClasses
(cPackages
(dStatements
Answer:C(see page72