欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    JAVA练习题.pdf

    • 资源ID:90863417       资源大小:5.48MB        全文页数:47页
    • 资源格式: PDF        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    JAVA练习题.pdf

    声明:本资料来自互联网,仅供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.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(IDE)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(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;声明:本资料来自互联网,仅供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.printlnCWelcome 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题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 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 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、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.*;声明:本资料来自互联网,仅供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 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 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 /25、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、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场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+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、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 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.println(i+第33题The following 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 Enter 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 java.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+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 class第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=JOptionPane.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 javax.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 because 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、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 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 0 and y 0;2 x 0;3 x 0 and z=100)System.out.println(Mtoo 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)声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途11System.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.println(nWelcome 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 always false at Point B4、count 100 is always true at Point C5、count 100 is always false at Point C笫56题How many times will the following code print nWelcome to Java,?int count=0;do System.out.println(MWelcome to Java1,);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(MWelcome to Java);while(count+9);System.out.println(count);1、82、93、104、115、0声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途12第58题Do the following two statements in(I)and(II)result in the samevalue in sum?(I):for(int i=0;i10;+i)sum+=i;)(ID: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 forloop line.2、The program compiles despite the semicolon(;)on the for loop line,anddisplays 4.3、The program compiles despite the semicolon(;)on the for loop line,anddisplays 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 isexecuted.2 The control is in the inner loop,and the next iteration of the inner loop isexecuted.3 The statement labeled next.4、The program terminates.第64题Suppose the input for number is 9.What is the output from runningthe 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.nextlnt();int i;boolean isPrime=true;for(i=2;i i is 3 followed by 9 is not prime3 i is 4 followed by 9 is prime4、i is 4 followed by 9 is not prime第65题Suppose your method does not return any value,which of thefollowing keywords can be used as a return type?1、void2 int3、double4、public5、None of the above第66题All Java applications must have a met hod.1、public static 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)第67题Does the return statement in the following method cause compileerrors?public static void main(String args)int max=0;if(max!=0)System.out.println(max);elsereturn;1、Yes2、No第68题Does the method call in the following method cause compile errors?public static void main(String args)Math.pow(2,4);1、Yes2、No第69 题 Supposestatic void nPrint(String message,int n)while(n 0)System.out.print(message);n-;声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途15)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(MA message1,k)?int k=2;nPrint(MA message1*,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 I)System.out.println(Mint,long*);return n;public static long xMethod(long n,long I)System.out.printlntlong,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 distinguishwhich xmethod to invoke.第72题Analyze the following code.public class Test public static void main(String args)System.out.println(max(1,2);)声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途16public static double max(int num1,double num2)System.out.println(Hmax(int,double)is invoked0);if(num1 num2)return num1;elsereturn num2;public static double max(double num1,int num2)System.out.println(Mmax(double,int)is invoked1 1);if(num1 num2)return num1;elsereturn num2;)1、The program cannot compile because you cannot have the printstatement in a non-void method.2、The program cannot compile because the compiler cannot determinewhich max method should be invoked.3、The program runs and prints 2 followed by Mmax(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 client can use a method without knowing how it is implemented.The details of the implementation are encapsulated in the method andhidden from the client who invokes the method.This is known as1、information hiding2、encapsulation3、method hiding4、simplifying method第74即What is Math.floor(3.6)?1、3.02、33、44、5.0第75题If you declare an array double口 list=3.4,2.0,3.5,5.5,list1 is1、3.42、2.03、3.44、5.55、undefined声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途17第76题If you declare an array double口 list=3.4,2.0,3.5,5.5,thehighest index in array list is.e,41、02、13、24、3第77题Suppose int i=5,which of the following can be used as an index forarray doubled t=new double100?1、i2、(int)(Math.random()*100)3、i+104 i+6.55、Math.random()*100第78题Analyze the following code.public class Test public static void main(String args)into x=new int3;System.out.println(Mx0 is +x0);1、The program has a compile error because the size of the array wasn tspecified when declaring the array.2、The program has a runtime error because the array elements are notinitialized.3、The program runs fine and displays x0 is 0.4、The program has a runtime error because the array element x0 is notdefined.第79题What would be the result of attempting to compile and run thefollowing code?public class Test public static void main(String args)doubled x=new double1,2,3;System.out.println(HValue is +x1);)1、The program has a compile error because the syntax new double1,2,3 is wrong and it should be replaced by 1,2,3).2、The program has a compile error because the syntax new double1,2,3 is wrong and it should be replaced by new double31,2,3;3 The program has a compile error because the syntax new double1,2,3 is wrong and it should be replaced by new double1.0,2.0,3.0;4、The program compiles and runs fine and the output Value is 1.0 isprinted.声明:本资料来自互联网,仅供2007级计算机科学与技术专业同学学习之用。内部资料,仅供学习。请勿使用于其他用途185、The program compiles and runs fine and the output Value is 2.0 isprinted.第80题Analyze the following code:public class Test public static void main(StringQ args)intQ x=new int5;int i;for(i=0;i x.length;i+)xi=i;System.out,println(xi);)1、The program displays 0 1 2 3 4.2、The program displays 4.3 The program has a runtime error because the last statement in the mainmethod causes ArraylndexOutOfBoundsException.4、The program has a compile error because i is not defined in the laststatement in the main method.第81 题In the following code,what is the printout for Iist2?class Test public static void main(String args)into listl

    注意事项

    本文(JAVA练习题.pdf)为本站会员(无***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开