Java练习题1(有答案).docx

上传人:rrsccc 文档编号:11077266 上传时间:2021-06-27 格式:DOCX 页数:67 大小:74.08KB
返回 下载 相关 举报
Java练习题1(有答案).docx_第1页
第1页 / 共67页
Java练习题1(有答案).docx_第2页
第2页 / 共67页
Java练习题1(有答案).docx_第3页
第3页 / 共67页
Java练习题1(有答案).docx_第4页
第4页 / 共67页
亲,该文档总共67页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《Java练习题1(有答案).docx》由会员分享,可在线阅读,更多相关《Java练习题1(有答案).docx(67页珍藏版)》请在三一文库上搜索。

1、第 1 题 _ is an object-oriented programming language.1 、 Java2、 C+3 、 C4 、 Ada5 、 Pascal答案12第 2 题 _ is Architecture-Neutral.1、 Java2、 C+3、 C4、 Ada5、 Pascal答案 1第 3 题 _ is a technical definition of the language that includes the syntax and semantics of the Java programming language.1 、 Java language spe

2、cification2 、 Java API3 、 Java JDK4 、Java IDE答案 1第 4题 _ consists of a set of separate programs for developingand 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 envir

3、onment (IDE)forrapidlydevelopingJavaprograms.Editing,compiling,building,debugging, and online help are integrated in one graphical user interface.1 、 Java language specification2 、 Java API3 、 Java JDK 4、 Java IDEThemainmethodheader答案iswritten4第as:6 题1 、public static void main(string args)2、 public

4、static void Main(String args)3、 public static void main(String args)4 、 publicstaticmain(Stringargs)5 、 publicvoid main(String args)答案 3第 7题 Which ofthe following statements is correct?1 、 Every linein a program must end with a semicolon.2、 Every statement in a program must end with a semicolon.3、 E

5、very 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 题 Which of the following statements is correct to display Welcome to Java on the console?1 、2 、3 、4 、5 、Welcome to Java );Welcome to Java);System.println( Welcome t

6、o Java );Welcome to Java );Welcome to Java);答案2 5第9题WhichJDKcommandiscorrecttorunaJavaapplicationinByteCode.class?1 、 java ByteCode2 、 java ByteCode.class3 、 javac ByteCode.java4 、 javac ByteCode 5、 JAVAC ByteCode答案1第 10 题Suppose you define a Java class as follows:public class Test In order to compi

7、le 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 a Java comment?

8、1、 /* comments */2、 / comments3、 - comments4、 /* comments */5、 * comments *答案35第 13题 Which of thefollowing are the reserved words?1、 public2、 static3、 void 4、 class答案 1234第 14题 To use JOptionPane inyour program, you may import it using:1、 import ;2、 import javax.swing.*;3、 import javax.*;4、 import j

9、avax.*.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 following are correct ways to declare variables?1 、 int length; int width;2 、 int length, wid

10、th;3 、 int length; width; 4、 int length, int width;答案12第 17题_istheJavaassignmentoperator.1、 =2、 :=3 、 =4 、=:答案3第 18题Whichofthefollowingassignmentstatements is incorrect.31、 i = j = k = 1;2 、 i = 1; j = 1; k = 1;3 、 i = 1 = j = 1 = k = 1; 4、 i = j = k = 1;答案 34第 19题Which of the following is a constan

11、t, according to Java namingconventions?1 、 MAX_VALUE2、 Test3、 read4、 ReadInt 5、 COUNT答案 15第 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 expressions will yield 0.5?1

12、、 1/22、 1.0/23、 (double) (1 / 2)4、 (double) 1 / 25、 1/2.0答案 245第 22题 Whichof the following expression results in a value 1?1、 2%12、 15%43、 25%5 4、 37%6答案 4第 23题 -25%5is _1、 12、 23、 34、 4 5、 0答案 5第 24题 -24 % -5 is _1、 32、 -33、 44、 -45、 0答案 4第 25题 To add number to sum, you write (Note:Java is case-sen

13、sitive)1 、 number += sum;2 、 number = sum + number;3 、 sum = Number + sum;4 、 sum += number;5 、 sum = sum + number;答案4 55第 26题 Suppose x is 1. What is x after x -= 1?1、 02、 13、 24、-15、 -2答案 1第 27 题 What is x afterthe following statements?int x = 1;int y = 2; x*= y + 1;1 、 x is 1;2 、 x is 2;3 、 x is

14、3; 4、 x is 4;第 28题What is y displayed?答案3publicclassTestpublicstaticvoidmain(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?publicclassTestpublicstaticvoidmain(String args) int x = 1; int y =x+ + x; y is +

15、 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 、 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 答案 4 第 31 题 Suppose x i

16、s 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 ofthe following statements display the character whose Unicode is stored invariable i?1 、 ;2 、 ;3、;4、 +);答案 2第 33题 The following codefragmentreadsintwonumber

17、s:Scannerinput=newScanner(System.in);inti= input.nextInt();doubled =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 inte

18、ger, 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 enter 1 2 3, when you run this program, what will be the output?import ; public class Test1 public static void main(String args

19、) Scanner input = new Scanner(System.in); Enter three numbers: ); double number1 = input.nextDouble(); double number2 =input.nextDouble(); double number3 =input.nextDouble();/ Compute average double average = (number1 + number2 + number3) / 3; / Display result;1、 1.02、 2.03、 3.074、 4.0答案 2第 35题 The

20、expression (int)(76.0252175 * 100)/ 100 evaluates to _.1 、 76.022、 763 、 76.0252175 4、76.03答案 2第 36题 According to Java namingconvention, which of the following names can be variables?1 、 FindArea2 、 findArea3 、 totalLength4 、 TOTAL_LENGTH5 、 class答案 23第 37题 The _ method displays an inputdialog for r

21、eading a string.1 、 String string = JOptionPane.showMessageDialog(null, Enter a string, Input Demo, JOptionPane.QUESTION_MESSAGE);2 、 String string = JOptionPane.showInputDialog(null, Enter a string, Input Demo, JOptionPane.QUESTION_MESSAGE);3 、 String string = JOptionPane.showInputDialog(Enter a st

22、ring, Input Demo, JOptionPane.QUESTION_MESSAGE);4 、 String string = JOptionPane.showInputDialog(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 voidmain(String arg

23、s) 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 valuewhen it is used in

24、i = i + 4;3 、 The program compiles 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题Supposex=10and y=10.What is x afterevaluating the expression (y 10) & (x- 10)?1 、 92、103、 11答案2第 40题 Suppose x=10 and y=10 what

25、 is x afterevaluating the expression(y = 10) | (x+ 10).1 、 92、103、 11答案2第 41题 Suppose x = 1, y = -1, and z = 1. What isthe printout of the following statement? (Please indent the statementcorrectly first.) if (x 0) if (y 0)x 0 and y 0); else if (z 0)x 0);1 、 x 0 and y 0;2 、 x 0;3 、 x 0 and z = 100) toohot); 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)答案 1 2 3 第 54 题 How many times will the following code print Welcome to Java?int count= 0; while(count 10) Welcome to Java); count+;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1