JAVA练习题.pdf
《JAVA练习题.pdf》由会员分享,可在线阅读,更多相关《JAVA练习题.pdf(47页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途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
2、.1、Java language specification2、Java API3 Java JDK4、Java 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(ID
3、E)forrapidly developing Java programs.Editing,compiling,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
4、(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 en
5、d with a semicolon;4、Every method must end with a semicolon;5 Every class must end with a semicolon;声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途2第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.prin
6、tlnCWelcome to Java*);3、System.println(Welcome to Java);4、System.out.print(Welcome to Java);5、System.out.print(nWelcome to Java);第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题Su
7、ppose you define a Java class as follows:public class Test In order to compile this program,the source code should 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、.java2、.obj3、.class4、.exe第12题Which o
8、f 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、void4、class第 14题To use JOptionPane in your program,you may import it using:1、import javax.swing.JOptionPane;2、import javax.swing
9、.*;3 import javax.*;声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途34、import javax/.JOptionPane;第15题Which of the following are correct names for variables according toJava naming conventions?1、radius2、Radius3、RADIUS4、findArea5、FindArea第16题Which of the following are correct ways to declare va
10、riables?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,acc
11、ording to Java namingconventions?1、MAX_VALUE2、Test3、read4、Readlnt5、COUNT第20题To declare an int variable number with initial value 2,you write1、int number=2L;2、int number=2I;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 /2
12、5、1 /2.0第22题Which of the following expression results in a value 1?1、2%12、15%4声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途43、25%54、37%6第23题25%5 is1、12、23、34、45、0第24题24%5 is1、32、-33、44、-45、0第25iTo add number to sum,you write(Note:Java is case-sensitive)1、number+=sum;2、number=sum+number;3、s
13、um=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场iWhat 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
14、+x+;System.out.println(My is +y);1、y is 1.2、y is 2.声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途53、y 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、
15、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+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.What is the printout oft
16、he 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.println(i+第33题The following
17、 code fragment reads in two numbers:Scanner input=new Scanner(System.in);int i=input.nextlntO;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 En
18、ter key.3、Enter an integer,an Enter key,a double value,and then the Enter key.声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途64、Enter a numeric value with a decimal point,a space,an integer,and thenthe Enter key.第34题If you enter 12 3,when you run this program,what will be theoutput?import ja
19、va.util.Scanner;public class Testi public static void main(StringQ args)Scanner input=new Scanner(System.in);System.out.print(MEnter three numbers:”);double numberl=input.nextDouble();double number2=input.nextDouble();double numbers=input.nextDouble();/Compute averagedouble average=(numberl+number2+
20、numbers)/3;/Display resultSystem.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、findArea3、total Length4、TOTAL_LENGTH5 clas
21、s第37题The method displays an input dialog for reading astring.1、String string=JOptionPane.showMessageDialog(null,MEnter a string”,Input Demo,JOptionPane.QUESTION_MESSAGE);2、String string=JOptionPane.showlnputDialog(null,Enter a string,Input Demo,JOptionPane.QUESTION_MESSAGE);3、String string=JOptionPa
22、ne.showlnputDialog(HEnter a string1*,InputDemo,JOptionPane.QUESTION_MESSAGE);4、String string=JOptionPane.showlnputDialog(null,Enter a string*);声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途75、String string=JOptionPane.showlnputDialog(Enter a string);第38题Analyze the following code.import jav
23、ax.swing.*;public class ShowErrors public static void main(String args)int i;int j;String s=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 beca
24、use i does not have an initial valuewhen it is used in i=i+4;3、The program compiles but has 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、1
25、1第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 thefollowing statement?(Please indent the statement correctly first.)if(x 0)if(y0)System.out.println(Mx 0 and y 0);else if(z 0)System.out.printing*0);1 x
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 练习题
限制150内