java练习题2.pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《java练习题2.pdf》由会员分享,可在线阅读,更多相关《java练习题2.pdf(94页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、 第1 题 is an object-oriented programming language.1、Java2、C+3、C4、Ada5、Pascal第2题 is Architecture-Neutral.1、Java2、C+3、C4、Ada5、Pascal第3题 is a technical definition of the language that includes thesyntax and semantics of the Java programming language.1、Java language specification2、Java API3、Java JDK4、Jav
2、a IDE第4题 consists of a set of separate programs for developing andtesting Java programs,each of which is invoked from a command line.1、Java language specification2、Java API3、Java JDK4、Java IDE第5题 provides an integrated development environment(IDE)forrapidly developing Java programs.Editing,compiling
3、,building,debugging,and online help are integrated in one graphical user interface.1、Java language specification2、Java API3、Java JDK4、Java IDE第6题The main method header is written as:1、public static void main(string args)2、public static void Main(StringO args)3、public static void main(StringQ args)4、
4、public static main(String args)5、public void main(StringO 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 se
5、micolon;5、Every class must end with a semicolon;第8题Which of the following statements is correct to display Welcome toJava 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.prin
6、t(Welcome to Java1);第9题Which JDK command is correct to run a Java application inByteCode.class?1、java ByteCode2、java ByteCode.class3、javac ByteCode.java4、javac ByteCode5、JAVAC ByteCode第 10题Suppose you define a Java class as follows:public class Test)In order to compile this program,the source code s
7、hould be stored in a filenamed1、Test.class2、Test.doc3、Test.txt4、Test.java5、Any name with extension.java第11 题The extension name of a Java bytecode file is1、.java2v.obj3、.class4、.exe第 12题Which of the following lines is not a Java comment?1、/*comments*/2、/comments3、-comments4、/*comments*/5、*comments*第
8、13题Which of the following are the reserved words?1、public2、static3、void4、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.*;4、import javax.*.JOptionPane;第 15题Which of the following are correct names for variabl
9、es according toJava naming conventions?1、radius2、Radius3、RADIUS4、find Area5、FindArea第 16题Which of the following are correct ways to declare variables?1、int length;int width;int length,width;int length;width;4%int length,int width;第17题 is the Java assignment operator.1、=2、:=3、=4、=:第 18题Which of the f
10、ollowing assignment statements is incorrect.j=j=k=1;2.i=1;j=1;k=1;3、i=1 =j=1 =k=1;4v j=j=k=1;第 19题Which of the following is a constant,according to Java namingconventions?1、MAX_VALUE2、Test3、read4、Read I nt5、COUNT第20题To declare an int variable number with initial value 2,you write1、int number=2L;2、in
11、t number=2I;3、int number=2;4%int number=2.0;第21 题Which of the following expressions will yield 0.5?1、1 122、1.0/23、(double)(1/2)4、(double)1125、1/2.0第22题Which of the following expression results in a value 1?1、2%12、15%4 3、25%54、37%6第23题25%5 is1、12、23、34、45、0第24题-24%-5 is1、32、33、44、-45、0第25题To add numb
12、er 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、5、-2第27题What is x after the following statements?intx=1;int y=2;x*=y+1;1s x is 1;2、xis 2;3、x is 3;4、x is 4;第28题What is
13、y displayed?public class Testpublic static void main(StringO args)int x=1;int y=x+x+;System.out.println(y is +y);)1、y is 1.2、yis 2.3、y is 3.4、y is 4.第29题What is y displayed in the following code?public class Testpublic static void main(StringO args)int x=1;int y=x+x;System.out.println(y is*+y);)1、y
14、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 isM+x+M 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 55、x is 5.5 and y is 5.0第31 题Suppose x is a char variable with a value b.
15、What is the printout ofthe statement System.out.println(+x)?1、a2、b3、c4、d第32题Suppose i is an int type variable.Which of the following statementsdisplay 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.pri
16、ntln(i+第33题The following code fragment reads in two numbers:Scanner input=new Scanner(System.in);int i=input.nextlnt();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 dou
17、ble 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,and thenthe Enter key.第34题If you enter 1 2 3,when you run this program,what will be theoutput?import java.util.Scanner;public class T
18、esti public static void main(StringO args)Scanner input=new Scanner(System.in);System.out.print(Enter three numbers:);double numberl=input.nextDouble();double number2=input.nextDouble();double numbers=input.nextDoubleQ;/Compute averagedouble average=(numberl+number2+number3)/3;/Display resultSystem.
19、out.println(average);)1、1.02、2.03、3.04、4.0第35题The expression(int)(76.0252175*100)/100 evaluates to1、76.022、763、76.02521754、76.03第36题According to Java naming convention,which of the following namescan be variables?1、FindArea2、find Area3、totalLength4、TOTAL.LENGTH5、class第37题The method displays an input
20、 dialog for reading astring.1、String string=JOptionPane.showMessageDialog(null,Enter a string1,Input Demo,JOptionPane.QUESTION_MESSAGE);2、String string=JOptionPane.showlnputDialog(null,MEnter a string,Input Demo”,JOptionPane.QUESTION_MESSAGE);3、String string=JOptionPane.showlnputDialog(Enter a strin
21、g,InputDemo,JOptionPane.QUESTION_MESSAGE);4 String string=JOptionPane.showlnputDialog(null,Enter a string);5、String string=JOptionPane.showInputDialogfEnter a string);第38题Analyze the following code.import javax.swing.*;public class ShowErrors public static void main(StringO args)int i;intj;String s=
22、JOptionPane.showlnputDialog(null,Enter an integer,Input,JOptionPane.QUESTION_MESSAGE);j=Integer.parselnt(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 i=i+4;3、The program compiles but has
23、a runtime error because i does not have aninitial 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(y10)&(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、1
24、1第41 题Suppose x=1,y=-1,and z=1.What is the printout of thefollowing statement?(Please indent the statement correctly first.)if(x 0)if(y 0)System.out.println(x 0 and y 0n);else if(z 0)System.out.println(x 0);1s x 0 and y 0;2、x v 0 and z 0;3s x 0 and z=100)System.out.println(too hot);else if(temperatu
25、re 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(MWelcome to Java);count+;)1、82、93、104、115、0第55题Analyze the following code.int count=0;while(count 100)/Point ASystem.out.print
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 练习题
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内