




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、end-of-line comments that should be ignored by the compiler are denoted usinga. two forward slashes ( / ).b. three forward slashes ( / ).c. a slash and a star ( /* ).d. a slash and two starts ( /* ).e. ans: a. two forward slashes ( / ).which of the following is not a valid java identifier?a. my valu
2、eb. $_aaa1c. widthd. m_xans: a. my value (identifiers may not contain blanks).which of the following cannot cause a syntax error to be reported by the java compiler?a. mismatched b. missing */ in a comment that begins with /*c. missing ;d. extra blank lines.ans: d. extra blank lines.which of the fol
3、lowing is not a syntax error?a. system.out.println( 'hello world!' ):b. system.out.println( "hello world!" );c. system.out.println( "hello world!" );d. system.out.println( hello world! );ans: c. system.out.println( "hello world!" );which command compiles the jav
4、a source code file welcome.java?a. cd welcome.javab. javac welcome.javac. java welcome.javad. compile welcome.javaans: b. javac welcome.javawhich command executes the java class file welcome.class?a. javac welcome.classb. java welcome.classc. java welcomed. run welcome.classans: c. java welcomewhich
5、 is the output of the following statements?system.out.print( "hello ");system.out.println( "world" );a. hello worldb. helloworldc. helloworldd. worldhelloans: a. hello worldwhich of the following characters is the escape character?a. *b. c. nd. "ans: b. which of the followin
6、g statements will print a single line containing "hello there"?a. system.out.println( "hello" );system.out.println( " there" ); b. system.out.println( "hello" , " there" ); c. system.out.println( "hello" );system.out.print( " there&quo
7、t; ); d. system.out.print( "hello" ); system.out.println( " there" ); ans: d. system.out.print( "hello" ); system.out.println( " there" );which of the following escape sequences represents carriage return?e. n.f. r.g. cr.h. c.ans: b. r.which of the following s
8、tatements would display the phase java is fun?a. system.out.println( "hellois funrjava " );b. system.out.println( 'java is fun' );c. system.out.println( ""java is fun"" );d. system.out.println( java is fun );ans: a. system.out.println( "hellois funrjava &qu
9、ot; );when method printf requires multiple arguments, the arguments are separated with _.a. colons (:).b. semicolons (;).c. commas (,).d. periods (.).ans: c. commas (,).which of the following statement displays hello world?a. system.out.printf( "%2s", "hello " "world" )
10、;b. system.out.printf( "%s %s", "hello", "world" );c. system.out.printf( "%s%s", "hello, world" );d. system.out.printf( "s% s%", "hello", "world" );ans: b. system.out.printf( "%s %s", "hello", "w
11、orld" );all import declarations must be placeda. inside the class declarations body.b. before the class declaration.c. after the class declaration.d. all of the above will work.ans: b. before the class declaration.which of the following is a variable declaration statement?a. int total;b. import
12、 java.util.scanner;c. public static void main( string args )d. / first string entered by userans: a. int total;a(n) _ enables a program to read data from the user.a. printf.b. import declaration.c. scanner.d. main.ans: c. scanner.which of the following is not a java primitive type?a. charb. bytec. r
13、eald. doubleans: c. realthe format specifier _ is a place-holder for an int value?a. %a.b. %d.c. %int.d. %s.ans: b. %d.which of the following statements does not alter a memory location?a. int a;b. number = 12;c. y = y + 2;d. width = integer.parseint(input);ans: a. int a;what is the value of result
14、after the following java statements execute?int a, b, c, d, result;a = 4;b = 12;c = 37;d = 51;result = d % a * c + a % b + a; a. 119b. 51c. 127d. 59ans: a. 119list the following operators in the order that they will be evaluated: -, *, /, +, %. assume that if two operations have the same precedence,
15、 the one listed first will be evaluated first.a. +, -, /, *, %.b. -, +, %, *, /.c. -, *, %, +, /.d. *, /, %, -, +.ans: d. *, /, %, -, +.which of the following is not an arithmetic operator?a. +b. -c. .d. %ans: c. .what will be output after the following java statements have been executed?int a, b, c
16、, d;a = 4;b = 12;c = 37;d = 51;if ( a < b ) system.out.println( "a < b" );if ( a > b ) system.out.println( "a > b" );if ( d <= c ) system.out.println( "d <= c" );if ( c != d ) system.out.println( "c != d" ); a. a < bc != db. a < bd <
17、= c c != d c. a > b c != dd. a < bc < d a != bans: a. a < b c != dwhich of the following is not a compilation error?a. neglecting to initialize a local variable in a method before it is used.b. placing a semicolon at the end of the first line of an if statement.c. omitting the left and r
18、ight parenthesis for the condition of an if statement.d. all are compilation errors.ans: b. placing a semicolon at the end of the first line of an if statement.each of the following is a relational or equality operator except:a. <=b. =!c. =d. >ans: b. =!chapter 3 introduction to classes and ob
19、jectssending a message to an object means that:a. you call a method of the object.b. you access a variable of the object.c. both (a) and (b).d. neither (a) nor (b).ans: a. method headers contain all of the following except: e. access modifier.f. left brace.g. name of method.h. return type.ans: b. le
20、ft brace.every java application is composed of at least one:a. local variableb. instance variablec. public class declarationd. imported classans c. public class declarationa class instance creation expression contains: a. parentheses.b. the new keyword.c. the name of the class.all of the above.ans:
21、d. all of the above.calling a method of another object requires which item?a. the dot separator.b. open and close braces.c. the new keyword.d. none of the above.ans a. the dot separator.what is the name of the values the method call passes to the method for the parameters?a. arguments.b. references.
22、c. objects.d. values.ans: a. arguments.which of the following is a scanner method?a. nextline.b. nexttext.c. nextword.d. readnext.ans: a. nextline.multiple parameters are separated with what symbol?a. dot separatorb. comma.c. parentheses.d. braces.ans: b. commas.which of the following is a valid ful
23、ly qualified name?a. scanner.b. java.scanner.c. util.scanner.d. java.util.scanner.ans: d. java.util.scanner.section 3.5 instance variables, set methods and get methodsattributes of a class are also known as:a. constructors.b. local variables.c. fields.d. classes.ans: c. fields.gradebooktest class th
24、at demonstrates class gradebookwhat is the default initial value of a string instance variable?a. ""b. "default"c. defaultd. nullans: d. nullset and get methodswhat type of methods allow a client of a class to assign values to a private instance variable?a. get methods. b. replac
25、e methods. c. assign methods. d. set methods. ans: d. set methods.section 3.6 primitive types vs. reference typeswhat is the default value of a reference?a. 0.b. "".c. null.d. default.ans: c. null.section 3.7 initializing objects with constructorsa default constructor has how many paramete
26、rs?a. 0.b. 1.c. 2.d. variable.ans: a. 0.section 3.8 floating-point numbers and type doublewhich two java primitive types store floating-point numbers?a. decimal and float.b. point and double.c. float and double.d. decimal and point.ans: c. float and double.what is the difference between a float and
27、a double?a. double variables store integers and float variables store floating-point numbers.b. double variables store numbers with smaller magnitude and coarser detail.c. double variables store numbers with larger magnitude and finer detail.d. none of the above.ans: c. double variables store number
28、s with larger magnitude and finer detail.floating-point number precision and memory requirementshow many significant digits does a double variable have?a. 7.b. 8.c. 14.d. 15.ans: d. 15.information is passed to a method in:a. the method name.b. that method's return.c. the method body.d. the argum
29、ents to the method.ans: d. the arguments to the method.programs designed for maintainability are constructed from small simple pieces or modules. modules in java are called:a. methods.b. classes.c. arguments.d. both methods and classes.ans: d. both methods and classesa well-designed methoda. perform
30、s multiple unrelated tasks.b. repeats code found in other methods.c. contains thousands of lines of code.d. performs a single, well-defined task.ans: d. performs a single, well-defined task.section 6.3 static methods, static field and class mathto declare a method as static, place the keyword static
31、 before _ in the methods declaration.a. the method modifier.b. the return type.c. the method name.d. the argument list.ans: b. the return type.which is a correct static method call of math class method sqrt?a. sqrt( 900 );.b. math.sqrt( 900 );.c. math.sqrt( 900 );.d. math math = new math(); math.sqr
32、t( 900 );.ans: c. math.sqrt( 900 );.which of the following methods is not in the math class?a. ceil.b. abs.c. parseint.d. log.ans: c. parseintwhich of the following can be an argument to a method?a. constants.b. variables.c. expressions.d. all of the above.ans: d. all of the above.method log takes t
33、he logarithm of its argument with respect to what base?a. 10b. ec. 2d. pians: b. emath class constants pi and eany field declared with keyword _ is constant.a. static.b. const.c. constant.d. final.ans: d. final.why is method main declared static?declaring main as _ allows the jvm to invoke main with
34、out creating an instance of the class.a. public.b. void.c. static.d. final.ans: c. static.section 6.4 declaring methods with multiple parametersvariables should be declared as fields only ifa. they are local variables.b. they are used only within a method.c. they are required for use in more than on
35、e method or their values must be saved between calls to the classs methods.d. they are arguments.ans: c. they are required for use in more than one method or their values must be saved between calls to the classs methods.consider the following java statements:int x = 9;double y = 5.3;result = calcul
36、atevalue( x, y );which of the following statements is false?a. a method is called with its name and parentheses.b. x and y are parameters.c. copies of x and y are passed to the method calculatevalue().d. x and y are arguments.ans: b. x and y are paramters.the parameter list in the method header and
37、the arguments in the method call must agree in:a. numberb. typec. orderd. all of the aboveans: d. all of the aboveassembling strings with string concatenationwhich operator can be used in string concatenation?a. *.b. +=.c. +.d. =+.ans: b. +=.when an object is concatenated with a string:a. a compilat
38、ion error occurs.b. a runtime error occurs.c. the objects tostring method is implicitly called to obtain the string representation of the object.d. the objects class name is used.ans: c. the objects tostring method is implicitly called to obtain the string representation of the object.section 6.5 no
39、tes on declaring and using methodsa static method can _.a. call only other static methods of the same class directly.b. manipulate only static fields in the same class directly.c. be called using the class name and a dot (.).d. all of the above.ans: d. all of the above.which statement is false?a. if
40、 a method does not return a value, the return-value-type in the method declaration can be omitted.b. placing a semicolon after the right parenthesis enclosing the parameter list of a method declaration is a syntax error.c. redeclaring a method parameter as a local variable in the methods body is a c
41、ompilation error.d. forgetting to return a value from a method that should return a value is a compilation error.ans: a. if a method does not return a value, the return-value-type in the method declaration can be omitted.section 6.6 method call stack and activation recordsstacks are known as _ data
42、structures.a. fifo.b. filo.c. lifo.d. lilo.ans: c. lifo.if more method calls occur than can have their activation records stored on the program execution stack, an error known as a _ occurs.a. stack overflow.b. stack rewind.c. stack full.d. stack empty.ans: a. stack overflow.section 6.7 argument pro
43、motion and castingwhich of the following promotions of primitive types is not allowed to occur?a. char to int.b. int to double.c. short to long.d. double to float.ans: d. double to float.which of the following primitive types is never promoted to another type?a. double.b. byte.c. boolean.d. both a a
44、nd c.ans: d. both a and c.section 6.8 java api packageswhich statement is not true.a. the java api consists of packages.b. the java api helps programmers avoid "reinventing the wheel."c. the java api consists of import declarations.d. the class javax.swing.japplet is part of the java api.a
45、ns: c. the java api consists of import declarations. (the java api is built from packages.)which of the following is not a package in the java api?a. ponent.b. java.awt.c. javax.swing.event.d. java.lang.ans: a. ponent.a. the java.text package contains classes for manipulating all of the following it
46、ems exceptb. classesc. numbersd. stringse. charactersans: a. classessection 6.9 case study: random-number generationmath static method random generates a random double value in the range from 0.0a. up to but not including 1.0b. up to and including 1.0c. up to and including 100.0d. up to but not incl
47、uding 100.0ans: a. up to but not including 1.0which statement below could be used to simulate the outputs of tossing a quarter to get heads or tails? suppose randomnumbers is a random object.a. randomnumbers.nextint( 7 );b. randomnumbers.nextint( 2 ); c. randomnumbers.nextint( 1 ); d. randomnumbers.
48、nextint( 25 ); ans: b. randomnumbers.nextint( 2 );rolling a six-sided diewhich statement below could be used to simulate the outputs of rolling a six-sided die? suppose randomnumbers is a random object.a. 1 + randomnumbers.nextint( 6 );b. 1 + randomnumbers.nextint( 2 ); c. 6 + randomnumbers.nextint(
49、 1 ); d. 3 + randomnumbers.nextint( 3 ); ans: a. 1 + randomnumbers.nextint( 6 );section 6.9.1 generalized scaling and shifting of random numbers6.which statement creates a random value from the sequence 2, 5, 8, 11 and 14. suppose randomnumbers is a random object.a. 2 + 5 * randomnumbers.nextint( 3
50、);b. 3 + 2 * randomnumbers.nextint( 5 );c. 5 + 3 * randomnumbers.nextint( 2 );d. 2 + 3 * randomnumbers.nextint( 5 );ans: d. 2 + 3 * randomnumbers.nextint( 5 );section 6.9.2 random-number repeatability for testing and debugging6.you can set a random objects seed at any time during program execution b
51、y calling the objects _ methods.a. changeseed.b. setseed.c. resetseed.d. updateseed.ans: b. setseed.section 6.10 case study: a game of chance (introducing enumerations)an enumeration is a special class that is introduced by the keyword _ and a type name.a. class.b. enum.c. enumeration.d. classenum.a
52、ns: b. enum.the identifiers in an enumeration _.a. must be unique.b. may be duplicated.c. must be lowercase letters and cannot contain numbers.d. must be uppercase letters and cannot contain numbers.ans: a. must be unique.section 6.11 scope of declarationsidentifiers in java have _ and _ scopes?a. m
53、ethod, class.b. class, block.c. block, statement.d. statement, file.ans: b. class, block.which of the following statements describes block scope?a. it begins at the opening of the class declaration and terminates at the closing b. it limits label scope to only the method in which it is declared.c. i
54、t begins at the identifier's declaration and ends at the terminating right brace ().d. it is valid for one statement only.ans: c. it begins at the identifier's declaration and ends at the terminating right brace ().which of these statements best defines scope?a. scope refers to the classes t
55、hat have access to a variable.b. scope determines whether a variables value can be altered.c. scoping allows the programmer to use a class without using its fully qualified name.d. scope is the portion of a program that can refer to an entity by its simple name.ans: d. scope is the portion of a prog
56、ram that can refer to an entity by its simple name.section 6.12 method overloadingoverloaded methods always have the same _.a. method name.b. return type.c. number of parameters.d. order of the parameters.ans: a. method name.an overloaded method is one thata. has a different name than another method, but the same parameters.b. has the same name as another method, but different parameters (by number, types or order of the types).c. has the same name and parameters as a method
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- TY/T 1110-2024體育賽事活動參賽指引編制規(guī)范
- 科協(xié)課題立項(xiàng)申報(bào)書范文
- 如何撰寫社科課題申報(bào)書
- 叉車租賃帶司機(jī)合同范本
- 課題申報(bào)書哪里查
- 班級管理 課題立申報(bào)書
- 班級建設(shè)課題申報(bào)書
- 合同范本 銷售合同
- 周結(jié)算合同范例
- 深圳課題申報(bào)書格式
- GB/T 7251.3-2017低壓成套開關(guān)設(shè)備和控制設(shè)備第3部分:由一般人員操作的配電板(DBO)
- 工程質(zhì)量回訪記錄
- GB/T 2572-2005纖維增強(qiáng)塑料平均線膨脹系數(shù)試驗(yàn)方法
- 2023年江蘇省中學(xué)生生物奧林匹克競賽試題及答案
- 維修質(zhì)量檢驗(yàn)制度
- 食管支架植入術(shù)后護(hù)理課件
- 品質(zhì)控制計(jì)劃(QC工程圖)
- 海外派遣人員管理辦法
- 混凝土灌注樁質(zhì)量平行檢查記錄(鋼筋籠)
- 汽車營銷學(xué)(全套課件)
- 現(xiàn)澆墩臺身軸線偏位、全高豎直度檢測記錄表
評論
0/150
提交評論