版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、第1題 is an object-oriented programming language.1、Java2、C+3、C4、Ada5、Pascal答案1 2第2 題 is Architecture-Neutral.1、Java2、C+3、C4、Ada5、Pascal答案 1第3 題 is a technical definition of the language that includesthe syntax and semantics of the Java programming language.1 、 Java language specification2 、 Java API3
2、、 Java JDK4 、 Java IDE答案 1第 4 題 consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line.1 、 Java language specification2 、 Java API3 、 Java JDK4 、 Java IDE答案 3第 5 題 provides an integrated development environment (IDE)building,for
3、rapidly developing Java programs. Editing, compiling, debugging, and online help are integrated in one graphical user interface.1 、 Java language specification2 、 Java API3 、 Java JDK 4、 Java IDE 答案 4 第 6 題The main method header is written as: 1 、public static void main(string args)2 、 public static
4、 void Main(String args)3 、 public static void main(String args)args) 5 、 public4 、 public static main(Stringvoid main(String args)答案 3 第 7 題 Which of1 、 Every line3、Every comment line must end with a semicolon;4、Every method must end with a semicolon;5、Every class must end with a semicolon;答案2第8 題 W
5、hich of the following statements is correct to display Welcome toJava on the console?1、Welcome to Java );2、"Welcome to Java");3、System.println( Welcome to Java );4、Welcome to Java );5、"Welcome to Java");答案 2 5第9 題 Which JDKcommand is correctto run aByteCode.class?1、java ByteCode2
6、、java ByteCode.class3、javac ByteCode.java4、javac ByteCode 5、 JAVAC ByteCode答案 1第10 題 Suppose you define a Java class as follows:Every statement in a program must end with a semicolon.2、Java applicationinthe following statements is correct?in a program must end with a semicolon.public class Test In o
7、rder to compile this program, the source code should be stored in a file named1 、 Test.class2 、 Test.doc3 、 Test.txt4 、 Test.java5 、 Any name with extension .java答案 4 第 11 題The extension name of a Java bytecode file is1 、 .java2 、 .obj3 、 .class4 、 .exe答案 3 第 12 題 Which of the following lines isnot
8、a Java comment?1、/* comments */2、/ comments3、- comments4、/* comments */5、* comments *答案 3 5第 13 題 Which of thefollowing are the reserved words?1 、 public2 、 static3 、 void 4 、 class 答案 1 2 3 4 第 14 題 To use JOptionPane in your program, you may import it using:1 、 import ;2 、 import javax.swing.*;3 、
9、 import javax.*;4 、 import javax.*.JOptionPane;答案 1 2第 15 題 Which of the following are correct names for variables according to Java naming conventions?1、radius2、Radius3、RADIUS4、findArea 5、 FindArea答案 1 4 第 16 題 Which of the followingare correct ways to declare variables?1、int length; int width;2、in
10、t length, width;3、int length; width; 4、 int length, int width;答案 12第 17 題 is the Javaassignmentoperator.1 、 =2 、 :=3 、 =4、答案 3 第 18 題Which of the followingassignment7statements is incorrect.1、i = j = k = 1;2、i = 1; j = 1; k = 1;3、i = 1 = j = 1 = k = 1; 4、 i = j = k = 1;答案 3 4 第 19 題Which of the foll
11、owing is a constant, according to Java naming conventions? 1 、 MAX_VALUE2 、 Test3 、 read4 、 ReadInt 5、 COUNT 答案 1 5 第 20 題 To declare an int variablenumber with initial value 2, you write1、int number = 2L;2、int number = 2l;3、int number = 2; 4、 int number = 2.0;答案 3 第 21題Which of the following expres
12、sions will yield 0.5?1、1 / 22、1.0 / 23、(double) (1 / 2)4、(double) 1 / 2 5、 1 / 2.0 答案 2 4 5 第 22 題 Whichof the following expression results in a value 1?1、2 % 12、15 % 43、25 % 5 4 、 37 % 6答案 4 第 23 題 -25 % 5 is 1、12、23、34、4 5 、 0 答案 5 第 24題-24 % -5 is 1、32、-33、44、-4 5 、 0 答案 4 第 25 題 To add number to
13、 sum, you write (Note:Java is case-sensitive)1、number += sum;2、number = sum + number;3、sum = Number + sum;答案4 、 sum += number;5 、 sum = sum + number;4 5第 26 題 Suppose x is 1. What is x after x -= 1?1 、 02 、 13 、 24 、 -1 5 、 -2 答案 1 第 27 題 What is x after the following statements?int x = 1;int y = 2;
14、 x*= y + 1;1 、 x is 1;2、x is 2;3、x is 3; 4 、 x is 4;答案 3第 28 題 What is y displayed?public class Test public static void main(String args) int x = 1; int y =x + x+; "y is " + y);1、y is 1.2、y is 2.3、y is 3.4、y is 4.答案 2 第 29 題 What is y displayed inthe following code?public class Test public
15、 static void main(String args) int x = 1; int y =x+ + x; "y is " + y);1、y is 1.2、y is 2.3、y is 3. 4 、 y is 4. 答案 3 第 30 題 What is the printout of the following code:double x = 5.5;int y = (int)x;"x is " + x + " and y is " + y);1、x is 5 and y is 62、x is 6.0 and y is 6.03
16、、x is 6 and y is 6Suppose x4、x is 5.5 and y is 5 5、 x is 5.5 and y is 5.0答案 4 第 31 題is a char variable with a value b . What is the printout of the statement1 、 a2 、 b3 、 c 4 、 d 答案 3 第 32 題 Suppose i is an int type variable. Which of the following statements display the character whose Unicode is s
17、tored in variable i?1 、 ;2 、 ;3、 ; 4 、 + " "); 答案 2 第 33 題 The following code fragment reads in two numbers: Scanner input = new Scanner(System.in); int i = input.nextInt(); double d = input.nextDouble();What are the correct ways to enter these two numbers?1 、 Enter an integer, a space, a
18、double value, and then the Enter key.2 、 Enter an integer, two spaces, a double value, and then the Enter key.3 、 Enter an integer, an Enter key, a double value, and then the Enter key.4 、 Enter a numeric value with a decimal point, a space, an integer, andthen the Enter key. 答案 1 2 3 第 34 題 If you
19、enter 1 2 3, when you run this program, what will be the output?import ; public class Test1 public static void main(String args) Scanner input = new Scanner(System.in);"Enter three numbers: "); double number1= input.nextDouble(); double number2 = input.nextDouble(); double number3 = input.
20、nextDouble();/ Compute average double average = (number1 + number2 + number3) / 3; / Display result1、1.02、2.03、3.04 、 4.0 答案 2 第 35 題 The expression (int)(76.0252175 * 100)/ 100 evaluates to .1 、 76.022 、 763 、 76.0252175 4 、 76.03 答案 2 第 36 題 According to Java naming convention, which of the follow
21、ing names can be variables?1 、 FindArea2 、 findArea3 、 totalLength4 、 TOTAL_LENGTH5 、 class 答案 2 3 第 37 題 The method displays an inputdialog for reading a string.1 、 String string = JOptionPane.showMessageDialog(null, "Enter a string","Input Demo", JOptionPane.QUESTION_MESSAGE);2
22、 、 String string = JOptionPane.showInputDialog(null, "Enter a string","Input Demo", JOptionPane.QUESTION_MESSAGE);3 、 String string = JOptionPane.showInputDialog("Enter a string", "InputDemo", JOptionPane.QUESTION_MESSAGE);4 、 String string = JOptionPane.showI
23、nputDialog(null, "Enter a string");5 、 String string = JOptionPane.showInputDialog("Enter a string"); 答案 2 4 5 第 38 題 Analyze the following code.import javax.swing.*; public classShowErrors public static void main(String args) int i; int j;String s = JOptionPane.showInputDialog(n
24、ull,"Enter an integer", "Input",JOptionPane.QUESTION_MESSAGE);j = Integer.parseInt(s);i = (i + 4);1 、 The program cannot compile because j is not initialized.2 、 The program cannot compile because i does not have an initial value when it is used in i = i + 4;3 、 The program compi
25、les but has a runtime error because i does not havean initial value when it is used in i = i + 4; 4、 The program compiles andruns fine. 答案 2 第 39 題 Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x- > 10)?1 、 92 、 10 3 、 11 答案 2 第 40 題 Suppose x=10 and y=1
26、0 what is x after evaluating the expression(y >= 10) | (x+ > 10).1 、 92 、 10 3 、 11 答案 2 第 41 題 Suppose x = 1, y = -1, and z = 1. What isthe printout of the following statement? (Please indent the statement correctly first.) if (x > 0) if (y > 0)"x > 0 and y > 0"); else i
27、f (z > 0)"x < 0 and z > 0");1、x > 0 and y > 0;2、x < 0 and z > 0;3、x < 0 and z < 0;4 、 no printout.答 案 2 第 42 題 Analyze the following code.boolean even = false;if (even) "It is even!");1 、 The code displays It is even!2 、 The code displays nothing.3 、 Th
28、e code is wrong. You should replace if (even) with if (even = true)4 、 The code is wrong. You should replace if (even) with if (even = true) 答案 2第 43 題 The following code displays .double temperature = 50; if (temperature >= 100) "too hot"); else if (temperature <= 40) "too cold
29、"); else"just right");1 、 too hot2 、 too cold3 、 just right4 、 too hot too cold just right答案3 第 44題Analyze the followingcode:Code 1:booleaneven; if(number%2 = 0)even = true; elseeven= false; Code 2:boolean even = (number % 2 = 0);1 、Code 1 has compile errors.2 、 Code 2 has compile err
30、ors.3 、 Both Code 1 and Code 2 have compile errors.4 、 Both Code 1 and Code 2 are correct, but Code 2 is better.答案 4第 45 題 The _ methodimmediatelyterminatestheprogram.1 、 System.terminate(0);2 、 System.halt(0);3 、 System.exit(0);4 、 System.stop(0);答案 3第 46 題What is the printout of the following swit
31、ch statement?char ch = a ; switch (ch) case a : case A :; break; case b : case B : ; break; case c : case C : ; break; case d : case D :1 、 abcd2 、 a3 、 aa4 、 ab 5 、 abc 答案 2 第 47 題 What is the printout of the following switch statement?char ch = b ;switch (ch) case a :; case b :; case c :; case d :
32、1 、 abcd2 、 bcd3 、 b4 、 bb5 、 bbb 答案 5 第 48 題 Analyze the following program fragment: int x; double d = 1.5; switch(d) case 1.0: x = 1; case 1.5: x = 2; case 2.0: x= 3;1 、 The program has a compile error because the required break statement is missing in the switch statement.2 、 The program has a co
33、mpile error because the required default case is missing in the switch statement.3、The switch control variable cannot be double.4、No errors.答案311第 49 題 Analyze the following code fragments that assign a boolean value to the variable even.Code 1: if (number %2 = 0) even = true; else even = false;Code
34、 2:even = (number % 2 = 0) ? true: false;Code 3: even = number % 2 = 0;1 、 Code 2 has a compile error, because you cannot have true and false literals in the conditional expression.2 、 Code 3 has a compile error, because you attempt to assign number to even.3 、 All three are correct, but Code 1 is p
35、referred.4 、 All three are correct, but Code 2 is preferred. 5、All three are correct, but Code 3 is preferred.outputs答 案 5 第 50 題 The statement "%3.1e", 1234.56)1、0.1e+042、0.123456e+043、0.123e+044、1.2e+03 5 、 1.23+03答案 4第 51 題 Analyze the following code: int i = 3434; double d = 3434;"
36、;%5.1f %5.1f", i, d);1 、 The code compiles and runs fine to display 3434.0 3434.0.2 、 The code compiles and runs fine to display 3434 3434.0.3、 i is an integer, but the format specifier %5.1f specifies a format for double value. The code has an error.答案 3 第 52 題 What is the valueof the followin
37、gexpression?true | true && false1 、 true2 、 false 答案 1 第 53 題 Which of the following statements are true?1、 (x > 0 && x < 10) is same as(x > 0) && (x < 10)2 、 (x > 0 | x < 10) is same as (x > 0) | (x < 10)3 、 (x > 0 | x < 10 && y < 0)
38、is same as (x > 0 | (x < 10 && y < 0)4 、 (x > 0 | x < 10 && y < 0) is same as (x > 0 | x < 10) && y < 0)print答案 1 2 3 第 54 題 How many times will the following code "Welcome to Java"?int count = 0; while(count < 10) "Welcome to Java
39、"); count+;1 、 82 、 93 、 104 、 11 5 、 0 答案 3 第 55 題 Analyze the following count = 0; while(count < 100) / Point A"Welcome to Java!"); count+;/ Point B/ Point C1 、 count < 100 is always true at Point A2 、 count < 100 is always true at Point B3 、 count < 100 is alwa
40、ys false at Point B4 、 count < 100 is always true at Point C 5、 count < 100 is alwaysfalse at Point C 答案 1 5 第 56 題 How many times will the following code print "Welcome to Java"?int count = 0;do "Welcome to Java"); while (count+ < 10);1 、 82 、 93 、 104 、 11 5 、 0 答案 4 第
41、 57 題 What is the value in count after the following loop is executed?int count = 0;do "Welcome to Java"); while (count+ < 9);1 、 82 、 93 、 104 、 11 5 、 0 答案 3 第 58 題 Do the following two statements in (I) and (II) result in the same value in sum?(I): for (int i = 0; i<10;+i) sum +=
42、i; (II): for (int i = 0;i<10; i+) sum += i;1 、 Yes 2 、 No 答案 1 第 59 題 Isthe following loop correct? for (; ; );1 、 Yes 2 、 No 答案 1 第 60 題Analyze the followingcode: publicclass Test public static void main(String args) int i = 0;for (i = 0; i < 10; i+); + 4);1 、 The program has a compile error
43、because of the semicolon (;) on the for loop line.2 、 The program compiles despite the semicolon (;) on the for loop line, and displays 4.3 、 The program compiles despite the semicolon (;) on the for loop line, and displays 14.4 、 The for loop in this program is same as for (i = 0; i < 10; i+) ;
44、+ 4); 答案 3 413第 61 題 To add 0.01 + 0.02 + . + 1.00, what order should you use to add the numbers to get better accuracy?1 、 add 0.01, 0.02, ., 1.00 in this order to a sum variable whose initial value is 0.2 、 add 1.00, 0.99, 0.98, .,0.02, 0.01 in this order to a sumwhose initial value is 0.答案 1 第 62
45、 題 What is sum after the following loop terminates?int sum = 0; intitem = 0; do item+; sum += item; if (sum > 4) break; while (item <5);1 、 52 、 63 、 7 4 、 8 答案 2 第 63 題 After the continue outer statement is executed in the following loop, which statement is executed? outer:for (int i = 1; i &
46、lt; 10; i+) inner:for (int j = 1; j < 10; j+) if (i * j > 50) continueouter; * j); next:1 、 The control is in the outer loop, and the next iteration of the outer loop is executed.2 、 The control is in the inner loop, and the next iteration of the inner loop is executed.3 、 The statement labele
47、d next.4 、 The program terminates. 答案 1 第 64 題 Suppose the number is 9. What is the output from running the following import ; public class Test public static void main(String args)variableinput forprogram? Scanner input = newScanner(System.in); "Enter an integer:"); int number = input.nex
48、tInt();int i;boolean isPrime = true; for (i = 2; i <number && isPrime; i+) if (number %i = 0) isPrime = false;"i is " + i); if (isPrime)+ " is prime"); else+ " is not prime");1、i is 3 followed by 9 is prime2、i is 3 followed by 9 is not prime3、i is 4 followed
49、by 9 is prime 4 、 i is 4 followed by 9 is not prime 答案 4 第 65 題 Suppose your method does not return any value, which of the following keywords can be used as a return type?1 、 void2 、 int3 、 double4 、 public5 、 None of the above 答案 1 第 66 題 All Java applications must have a method .1 、 public static
50、 Main(String args)2 、 public static Main(String args)3 、 public static void main(String args)4 、 public void main(String args) 5、 public static main(String args)答案 3 第 67 題 Does the return statement in the following method cause compile errors?public static void main(String args) int max = 0; if (ma
51、x != 0) else return;1 、 Yes 2No 答案 2 第 68 題 Does the method call in the followingmethod cause compile errors?public static void main(String args) Math.pow(2, 4);1 、 Yes 2 、 No 答案 2 第 69 題Supposestatic void nPrint(String message, while (n > 0) ; n-; What is the printout of the call nPrint( a , 4)?
52、1 、 aaaaa2 、 aaaa3 、 aaa4 、 invalid call 答案 4 第 70 題Supposestatic void nPrint(String message, while (n > 0) ; n-; What is k after invoking nPrint("A message", k)?int k = 2; nPrint("Amessage", k);1 、 02 、 13 、 2 4 、 3 答案 3 第 71 題 Analyze the following code: public class Test pu
53、blic static void main(String args)int n)int n)17, 500L);public static int xMethod(int n, long l) "int, long"); return n; public static long xMethod(long n, long l) "long, long"); return n;1 、 The program displays int, long followed by 5.2 、 The program displays long, long followe
54、d by 5.3 、 The program runs fine but displays things other than 5.4 、 The program does not compile because the compiler cannot distinguish which xmethod to invoke.答 案 1 第 72 題 Analyze the following code. public class Test public static void main(String args) , 2);public static double max(int num1, d
55、ouble num2) "max(int, double) is invoked"); num2) return num1; else return num2;public static double max(double num1, int num2) "max(double, int) is invoked"); num2) return num1; else return num2;1 、 The program cannot compile statement in a non-void method.if (num1 >if (num1
56、>because you cannot have the print2 、 The program cannot compile because the compiler cannot determine which max method should be invoked.3 、 The gramrunsandprints2followedby"max(int,double)"is4 、 Theprogramrunsandprints2followedby"max(double,int)"isinvoked.5 、 The program runs and prints &
溫馨提示
- 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版嬰幼兒用品包裝袋定制合同3篇
- 2025年度房產(chǎn)買賣雙方傭金結(jié)算協(xié)議范本8篇
- 2025年度智能硬件產(chǎn)品銷售合同范本4篇
- 2025年度錨桿工程設(shè)備租賃與維護(hù)服務(wù)合同4篇
- 二零二五版養(yǎng)老院食堂運(yùn)營管理與承包協(xié)議書3篇
- 二零二四全新老年監(jiān)護(hù)服務(wù)協(xié)議范本下載6篇
- 二零二五年度汽車保險代理服務(wù)協(xié)議2篇
- 1 我們班四歲了 說課稿-2024-2025學(xué)年道德與法治四年級上冊統(tǒng)編版
- 二零二五年度離婚后按揭房產(chǎn)權(quán)屬分割及子女教育經(jīng)費(fèi)協(xié)議3篇
- 二零二五年度中小企業(yè)財務(wù)健康診斷與改善合同3篇
- GB/T 8005.2-2011鋁及鋁合金術(shù)語第2部分:化學(xué)分析
- GB/T 37234-2018文件鑒定通用規(guī)范
- GB/T 31888-2015中小學(xué)生校服
- 質(zhì)量檢查考核辦法
- 不動產(chǎn)登記實務(wù)培訓(xùn)教程課件
- 云南省普通初中學(xué)生成長記錄-基本素質(zhì)發(fā)展初一-初三
- 2023年系統(tǒng)性硬化病診斷及診療指南
- 外科醫(yī)師手術(shù)技能評分標(biāo)準(zhǔn)
- 《英語教師職業(yè)技能訓(xùn)練簡明教程》全冊配套優(yōu)質(zhì)教學(xué)課件
- 采購控制程序
- 六年級上冊數(shù)學(xué)簡便計算題200題專項練習(xí)
評論
0/150
提交評論