




已阅读5页,还剩43页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
资料供 2008 级计算机科学与技术专业使用 第 1题 _ is an object-oriented programming language.1、 Java2、 C+3、 C4、 Ada 5、 Pascal 第 2题 _ is Architecture-Neutral.1、 Java2、 C+3、 C4、 Ada 5、 Pascal第 3题 _ is a technical definition of the language that includes the syntax and semantics of the Java programming language.1、 Java language specification2、 Java API3、 Java JDK 4、 Java IDE第 4题 _ consists of a set of separate programs for developing and testing Java programs, eachof which is invoked from a command line.1、 Java language specification2、 Java API3、 Java JDK 4、 Java IDE第 5题 _ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface.1、 Java language specification2、 Java API3、 Java JDK 4、 Java IDE 第 6题 The main method header is written as: 1、 public static void main(string args)2、 public static void Main(String args)3、 public static void main(String args)4、 public static main(String args) 5、 public void main(String args) 第 7题 Which of the following statements is correct?1、 Every line in a program must end with a semicolon.2、 Every statement in a program must end with a semicolon.3、 Every comment line must end with a semicolon;4、 Every method must end with a semicolon;5、 Every class must end with a semicolon;第 8题 Which of the following statements is correct to display Welcome to Java on the console?1、 System.out.println( Welcome to Java ) ;2、 System.out.println(Welcome to Java);3、 System.println( Welcome to Java ) ;4、 System.out.print( Welcome to Java ) ; 5、 System.out.print(Welcome to Java);第 9题 Which JDK command is correct to run a Java application in ByteCode.class? 1、 java ByteCode2、 java ByteCode.class3、 javac ByteCode.java4、 javac ByteCode 5、 JAVAC ByteCode 第 10题 Suppose you define a Java class as follows:public class Test In order to compile this program, the source code should be stored in a file named 1、 Test.class2、 Test.doc3、 Test.txt4、 Test.java5、 Any name with extension .java第 11题 The extension name of a Java bytecode file is1、 .java2、 .obj3、 .class 4、 .exe 第 12题 Which of the following lines is not a Java comment?1、 /* comments */2、 / comments3、 - comments4、 /* comments */ 5、 * comments * 第 13题 Which of the following are the reserved words?1、 public2、 static3、 void 4、 class 第 14题 To use JOptionPane in your program, you may import it using:1、 import javax.swing.JOptionPane;2、 import javax.swing.*;3、 import javax.*;4import javax.*.JOptionPane;第 15题 Which of the following are correct names for variables according to Java naming conventions?1、 radius2、 Radius3、 RADIUS4、 findArea 5、 FindArea 第 16题 Which of the following are correct ways to declare variables?1、 int length; int width;2、 int length, width;3、 int length; width; 4、 int length, int width; 第 17题 _ is the Java assignment operator.1、 =2、 :=3、 = 4、 =: 第 18题 Which of the following assignment statements 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 ;第 19题 Which of the following is a constant, according to Java naming conventions?1、 MAX_VALUE2、 Test3、 read4、 ReadInt5、 COUNT第 20题 To declare an int variable number with initial value 2, you write1、 int number = 2 L;2、 int number = 2 l;3、 int number = 2 ; 4、 int number = 2.0 ; 第 21题 Which of the following expressions will yield 0.5 ?1、 1 / 22、 1.0 / 23、 (double) (1 / 2)4、 (double) 1 / 25、 1 / 2.0 第 22题 Which of the following expression results in a value 1 ?1、 2 % 12、 15 % 4325 % 54、 37 % 6第 23题 1、 12、 23、 34、 45、 0-25 % 5 is _第 24题 1、 32、 -33、 44、 -45、 0-24 % -5 is _第 25题To add number to 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; 第 26题 Suppose x is 1. What is x after x -= 1 ?1、 02、 13、 24、 -15、 -2第 27题 What is x after the following statements?int x = 1 ;int y = 2 ; x *= y + 1 ; 1、 x is 1 ;2、 x is 2 ;3、 x is 3 ;4、 x is 4 ; 第 28题 What is y displayed? public class Test public static void main(String args) int x = 1 ;int y = x + x+;System.out.println(y is + y);1、 y is 1.2、 y is 2.3y is 3.4、 y is 4. 第 29题 What is y displayed in the following code?public class Test public static void main(String args) int x = 1 ;int y = x+ + x;System.out.println(y is + y);1、 y is 1.2、 y is 2.3、 y is 3.4、 y is 4.第 30题 What is the printout of the following code:double x = 5.5 ; int y = ( int)x;System.out.println(x is + x + and y is + y);1、 x is 5 and y is 62、 x is 6.0 and y is 6.03、 x is 6 and y is 64、 x is 5.5 and y is 5 5、 x is 5.5 and y is 5.0第 31题 Suppose x is a char variable with a value b . What is the printout of the statement System.out.println(+x)?1、 a2、 b3、 c 4、 d第 32题 Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i?1、 System.out.println(i);2、 System.out.println(char)i);3、 System.out.println(int)i); 4、 System.out.println(i + ); 第 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 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.4Enter a numeric value with a decimal point, a space, an integer, and then the Enter key.第 34题 If you enter 1 2 3, when you run this program, what will be the output?import java.util.Scanner; public class Test1 public static void main(String args) Scanner input = new Scanner(System.in); System.out.print(Enter three numbers: ); double number1 = input.nextDouble(); double number2 = input.nextDouble(); double number3 = input.nextDouble();/ Compute averagedouble average = (number1 + number2 + number3) / 3 ;/ Display resultSystem.out.println(average); 1、 1.02、 2.03、 3.04、 4.0第 35题 The expression (int)(76.0252175 * 100) / 100 evaluates to _.1、 76.022、 763、 76.0252175 4、 76.03第 36题 According to Java naming convention, which of the following names can be variables? 1、 FindArea2、 findArea3、 totalLength4、 TOTAL_LENGTH5、 class 第 37题 The _ method displays an input dialog for reading a string.1、 String string = JOptionPane.showMessageDialog(null, Enter a string,Input Demo, JOptionPane.QUESTION_MESSAGE);2、 String string = JOptionPane.showInputDialog(null, Entera string,Input Demo, JOptionPane.QUESTION_MESSAGE);3、 String string = JOptionPane.showInputDialog(Enter a string, InputDemo, JOptionPane.QUESTION_MESSAGE);4、 String string = JOptionPane.showInputDialog(null, Entera string);5 String string = JOptionPane.showInputDialog(Enter a string); 第 38题 Analyze the following code.import javax.swing.*; public class ShowErrors public static void main(String args) int i;int j;String s = JOptionPane.showInputDialog(null,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 compiles but has a runtime error because i does not have an initial value when it is used in i = i + 4 ; 4、 The program compiles and runs fine. 第 39题 Suppose x=10 and y=10. What is x after evaluating the expression (y 10) & (x- 10) ?1、 92、 103、 11第40题 Suppose x=10 and y=10 what is x after evaluating the expression (y = 10) | (x+ 10).1、 92、 103、 11第 41题 Suppose x = 1, y = -1, and z = 1. What is the printout of the following statement? (Please indent the statement correctly first.) if (x 0) if (y 0)System.out.println(x 0 and y 0 ); else if (z 0)System.out.println(x 0 );1、 x 0 and y 0 ;2、 x 0 ;3、 x 0 and z = 100)System.out.println(too hot); else if (temperature 0 & x 0) & (x 0 | x 0) | (x 0 | x 10 & y 0 | (x 10 & y 0 | x 10 & y 0 | x 10) & y 0)第 54题 How many times will the following code print Welcome to Java?int count = 0 ; while (count 10) System.out.println(Welcome to Java); count+; 1、 82、 93、 104、 115、 0第 55题 Analyze the following count = 0 ; while (count 100) / Point ASystem.out.println(Welcome to Java!); count+; / Point B / Point C1、 count 100 is always true at Point A 2、 count 100 is always true at Point B3、 count 100 is always false at Point B4、 count 100 is always true at Point C 5、 count 100 is always false at Point C 第 56题 How many times will the following code print Welcome to Java?int count = 0 ;do System.out.println(Welcome to Java); while (count+ 10) ;1、 82、 93、 104、 115、 0第 57题 What is the value in count after the following loop is executed?int count = 0 ;do System.out.println(Welcome to Java); while (count+ 9) ;System.out.println(count);1、 82、 93、 104、 115、 0第 58题 Do the following two statements in (I) and (II) result in the same value in sum?( I ):for (int i = 0; i10; +i) sum += i;( II ):for (int i = 0; i10; i+) sum += i; 1、 Yes2、 No第 59题 Is the following loop correct?for (; ; ) ;1、 Yes2、 No第 60题 Analyze the following code: public class Test public static void main (String args) int i = 0 ; for (i = 0; i 10; i+);System.out.println(i + 4) ;1、 The program has a compile error 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 4) break; while (item 5) ;1、 52、 63、 74、 8第 63题 After the continue outer statement is executed in the following loop, which statement is executed? outer:for (int i = 1; i 10; i+) inner:for (int j = 1; j 50) continue outer;System.out.println(i * 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 labeled next.4、 The program terminates. 第 64题 Suppose the input for number is 9. What is the output from running the following program? import java.util.Scanner; public class Test public static void main(String args) Scanner input = new Scanner(System.in); System.out.print(Enter an integer: );int number = input.nextInt();int i;boolean isPrime = true; for (i = 2; i 0) System.out.print(message);n-;What is the printout of the call nPrint( a , 4) ?1、 aaaaa2、 aaaa3、 aaa4、 invalid call第 70题 Supposestatic void nPrint(String message, int n) while (n 0) System.out.print(message);n-;What is k after invoking nPrint(A message, k)?int k = 2 ; nPrint(A message, k);1、 02、 13、 24、 3第 71题 Analyze the following code: public class Test public static void main(String args) System.out.println(xMethod(5, 500L) ;public static int xMethod(int n, long l) System.out.println(int, long);return n; public static long xMethod(long n, long l) System.out.println(long, long); return n;1、 The program displays int, long followed by 5.2、 The program displays long, long followed 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. 第 72题 Analyze the following code. public class Test public static void main(String args) System.out.println(max(1, 2) ;资料来自互联网,经本人整理,内部教学使用不得用于任何商业用途.17. 资料供 2008 级计算机科学与技术专业使用 public static double max(int num1, double num2) System.out.println(max(int, double) is invoked); if (num1 num2) return num1;else return num2; public static double max(double num1, int num2) System.out.println(max(double, int) is invoked); if (num1 num2) return num1;else return num2;1、 The program cannot compile because you cannot have the print statement in a non-void method.2、 The program cannot compile because the compiler cannot determine which max method should be invoked.3、 The program runs and prints 2 followed by max(int, double) is invoked.4、 The program runs and prints 2 followed by max(double, int) is invoked.5、 The program runs and prints max(int, double) is invoked followed by 2. 第73题 The
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论