《java练习题(一).pdf》由会员分享,可在线阅读,更多相关《java练习题(一).pdf(47页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、j a v a 练 习 题(1)试卷编号:5 62 6所属语言:j a v a 所属方案:j a v a li a n x iK 第 1 题1 填空(1 分)(题号:1 0 8)创建一个名为m y b a o 的包的语句是【1】。答案:D o包裹K 第 2 题 填空(1 分)(题号:1 1 6)程序的结构有顺序、【1】、循环答案:D o选择K 第 3 题 填空(1 分)(题号:6)假设=h e llo,B =“世界”,执行A+B 的结果是 1 L答案:Do He llo W o r ld(第 4 题】填空(1 分)(题号:7)在 j a v a 中所实现的多维数组,实际上是由一维数组构成的 I
2、L答案:D o数组或阵列或数组的数组K 第 5 题 填空(1 分)(题号:1 1 8)1 先判断后执行的循环语句是【。答案:D o虽然K 第 6 题 填空(1 分)(题号:1 2 2)j a v a 关系运算符中表示不等于的是 lo答案:1 )o!=K 第 7 题1 填空(1 分)(题号:3)j a v a 语言具有可移植性、高性能、健壮性、安全性和独立于体系结构 的 1 1】特点。答案:D o跨平台K 第 8 题1 填空(1 分)(题号:1 1 4)若 x =5,y =1 0,X=Y 则的逻辑值为【1】。答案:D o假K 第 9 题 填空(1 分)(题号:1)j a v a 源文件中最多只能
3、有一个【1】类,其他类的个数不限。答案:l)o公共或公共K 第 1 0 题1 填空(1 分)(题号:1 1 5)j a v a 语言的循环包括为循环、而循环和【1】循环。答案:D o做(第 1 1 题】填空(1 分)(题号:5)逻辑表达式(2 4)和(5 =4 +1)显示的结果是 1】答案:D o真正的K 第 1 2 题 填空(1 分)(题号:1 0 9)假设有以下代码i n t =2;i n t =3;字符串“=”;执行A +B +C的结果是lo答案:1 )o 5 f r o m 太阳K 第 1 3 题】填空(1 分)(题号:1 2 5)双类型的数据用【1】个字节表示。答案:D o八K 第
4、1 4 题 填空(1 分)(题号:1 1 0)使用字节读取文件FilelnputStream,字节流【1】直接操作Unicode字符。答案:1)0不能 Fifteenth questions fill in(1)(item number:117)Instantiating an object can generate multiple objects and usethe 1 operator to allocate memory space for objectsAnswer:1).NEW“Sixteenth questions fill in(1)(item number:111)The
5、keyboard type the string and displays it on the computerscreen,where the data source is 1Answer:1)keyboard Seventeenth questions fill in(1)(item number:123)Boolean types have only two constant values:1 and false.Answer:1).True Eighteenth questions fill in(1)(item number:112)According to the composit
6、ion of the program and the operatingenvironment,the Java source program is divided into two majorcategories:1 program and Applet programAnswer:1)application or Application or Applications Nineteenth questions fill in(1)(item number:126)The assignment operator is represented by 1Answer:1)=Twentieth q
7、uestions fill in(1)(item number:113)In the Java language,the suffix is called 1 source code,compiled to form a suffix called.Class bytecode fileAnswer:1).Java“Twenty-first questions fill in(1)(item number:121)In the Java relational operator,the expression is equal to 1Answer:=1).“Twenty-second quest
8、ions7 fill in(1)(item number:2)Each Java application can include many methods,but there mustbe one and only one 1 methodAnswer:1)main or main()or main()“Twenty-third questions fill in(1)(item number:120)The bitwise or the operator is 1Answer:1)I.“Twenty-fourth questions fill in(1)(item number:8)Arra
9、y definition:int MylntArray=10,20,30,40,50,60,70);After the execution of the fol lowing statements,the output is1Int s=0;For(int i=0;iMyIntArray,length;i+)If(i%2=0)s+=MyIntArrayi;System,out.printin(s);Answer:1)160“Twenty-fifth questions fill in(1)(item number:11)Read the following code sectionPublic
10、 class Test2Public,static,void,main(String,args)System,out.printin(5/2);)The result of the output is 1Answer:1)2“Twenty-sixth questions fill in(1)(item number:119)The bitwise and bitwise operators are 1Answer:1)-Twenty-seventh questions fill in(1)(item number:124)Statement i=your hobby”.Length();the
11、 value saved in I is1Answer:1)4“Twenty-eighth questions7 fill in(1)(item number:107)Applet is a Java class that can be embedded in the format of1 and can run in a browserAnswer:1).“Seventh questions single choice(1)(item number:1558)The main method of the application has the following statement,The
12、value saved isInt a=4,1,8,5,9;A:1B:8C:5D:9Answer:C“Eighth questions single choice(1)(item number:1550)Defining the key used by the package is A:importB:implementsC:packageD:extendsAnswer:C“Ninth questions single choice(1)(item number:1551)The key to the introduction of the Java class is A:implements
13、B:packageC:extendsD:importAnswer:D“Tenth questions7 single choice(1)(item number:1548)In the Java source code,there are the following methods toillustrate objects in class A:1,A,a=new,A();2 A al;Al=new,A();3 a2=new A();The following statement is trueA:only first 1ines can be compiledB:first,second l
14、ines can compile and compile errors in thethird lineC:first,second,third lines can compile and compile errorsin the second,third lineD:first,second,third,all statements are correctAnswer:BEleventh questions single choice(1)(item number:1557)The main method of the application has the following statem
15、ent,IThe value saved is Int a=ll,21,43,24,15,61;I=a.length-1;A:6B:5C:7D:2Answer:B“Twelfth questions single choice(1)(item number:1488)The default layout manager for JPanel is A:FlowLayoutB:CardLayoutC:BorderLayoutD:GridLayoutAnswer:A“Thirteenth questions single choice(1)(item number:1543)In the main
16、 method,the following codeFor(int i=l;i=10;i+=2)(If(i=5)continue;System.out.print(i=+i);)The running results are as followsA:i=l1=31=71=9B:i=l1=31=51=7C:i=l1=31=91=1 1D:i=l1=21=41=6A n s w e r:A“F o u r t e e n t h q u e s t i o n s s i n g le c h o i c e (1)(i t e m n u m b e r:1 5 5 5)After execut
17、ing the code int x=new int(25),thenWhat is said is correctA:x24 is 0B:x24 undefinedC:x25 is 0D:x0 is emptyAnswer:AFifteenth questions single choice(1)(item number:1459)The following statement in the Java language is correctA:Java is case insensitiveThe B:source file name must be the same as the clas
18、s name ofthe public typeC:source file name,whose extension is called.JarThe number of public classes in the D:source file is unlimitedAnswer:BSixteenth questions7 single choice(1)(item number:1541)The following statement belongs to a multi-branch statementA:ifB:switchC:do-whileD:forAnswer:BSeventeen
19、th questions single choice(1)(item number:1539)The stream in the computer is A:bytes flowingB:flow objectsC:mobile filesD:streaming data bufferAnswer:D“Eighteenth questions single choice(1)(item number:1570)In the following dual loop structure,the loop at which breakends is For(int i=l;i=10;i+)(Oute
20、r loopFor(int j=l;j=5;j+)(Inner circulation bodyBreak;)A:external circulationB:internal circulationC:internal circulation and external circulationD:or more is wrongAnswer:BNineteenth questions single choice/7(1)(item number:1547)Which of the following assignment statements is correct?A:char a=15;B:i
21、nt a=21.2;C:int a=15.Of;D:int a=(int)15;Answer:D,Twentieth questions single choice(1)(item number:1553)In the method call,the statement used to return the value isA:breakB:continueC:returnD:exitAnswer:C“Twenty-first questions single choice(1)(item number:1538)Following program segment:Boolean a=fals
22、e;Boolean b=true;Boolean c=(a&b)&(b!);Boolean result=(a&b)&(b);After execution,the correct result is A:c=false;result=false;B:c=true;result=true;C:c=true;result=false;D:c=false;result=true;Answer:A“Twenty-second questions single choice(1)(item number:1458)The feature of ensuring the portability of J
23、ava language is.A:object orientedB:securityC:can be cross platformD:distributed computingAnswer:C“Twenty-third questions single choice(1)(item number:1542)A loop should normally contain the following contentsA:initialization sectionB:loop body partC:iteration section and termination sectionD:or more
24、Answer:D“Twenty-fourth questions single choice(1)(item number:1469)Divide the number of operands by operator,operator:the typeis A:three yuanB:two yuanC:four yuanD:yuanAnswer:A“Twenty-fifth questions single choice(1)(item number:1466)The main method of the application has the following statement,and
25、 the result of the output is“String str=I love this game.”;System,out.printin(str.substring(2,6);A:I loveB:loveC:love thisD:or more is wrongAnswer:B“Twenty-sixth questions single choice(1)(item number:1568)The data in type int occupies bytes in memory bytesA:1B:3C:4D:2Answer:C“Twenty-seventh questio
26、ns single choice(1)(item number:1540)The switch statement cannot be used for the fol lowing data typesA:doubleB:byteC:shortD:chartAnswer:A“Twenty-eighth questions single choice(1)(item number:1576)Represents the bitwise logical operation and the operator isA:B:|C:&D:&Answer:D“Twenty-ninth questions
27、single choice(1)(item number:1561)The main method of the application has the following statement,lenThe value saved is Int len;Len=Java Applet!”Length();A:9B:10C:llD:12A n s w e r:D Th i r t i e t h q u e s t i o n s s i n g le c h o i c e (1)(i t e m n u m b e r:1 5 4 4)Th e f o llo w i n g o p t i
28、 o n i s t h e le g a l i d e n t i f i e r o f 口A:c la s sB i h e llo!C:C la s sD:2 xA n s w e r:C“Th i r t y-f i r s t q u e s t i o n s s i n g le c h o i c e (1)(i t e m n u m b e r:1 5 7 2)Th e k e y w o r d d e f i n i n g t h e s i n g le p r e c i s i o n d a t a i s A:i n tB:f lo a tC:d o u
29、 b leD:c h a rA n s w e r:B“Thirty-second questions7 single choice(1)(item number:1461)Compiling the Java Application source file produces thecorresponding bytecode file,whose extension is 口A:.javaB:.htmlC:.classD:.exeAnswer:C“Thirty-third questions single choice(1)(item number:1556)The main method
30、of the application has the following statement,IThe value saved is Int a=2,3,4,5,6;I=a.length;A:4B:5C:6D:7Answer:BThirty-fourth questions single choice(1)(item number:1552)The child class inherits the keyword of the parent classA:packageB:extendsC:importD:implementsAnswer:Bz/Thirty-fifth questions7
31、single choice(1)(item number:1484)The following class declarations are correctA:abstract,final,class,HI B:abstract,private,move()C:protected private number;Dipublic,abstract,class,Car,.Answer:D“Thirty-sixth questions single choice(1)(item number:1482)Method writes the method head for a non parametri
32、c,no returnvalue of the AB class,so that it can be called using the classname AB as a prefix,in the form of the method headerA:static,void,method()Bipublic,void,method()C:final,void,method()D:abstract,void,method()Answer:A“Thirty-seventh questions single choice(1)(item number:1457)The type of Java l
33、anguage is.A:process oriented languageB:object oriented languageC:assembly languageD:formal languageAnswer:BThirty-eighth questions single choice(1)(item number:1470)After executing the following program,the correct result ofthe output is Public,class,Test Public,static,void,main(String,args)System,
34、out.print(100%3);System,out.print;System,out.print(100%3.0);A:l,1B:l,1.0C:l.0,1D:l.0,1.0Answer:B“Thirty-ninth questions single choice(1)(item number:1481)In Java,the following constraints are incorrectA:privateB:publicC:protectedD:friendAnswer:DFortieth questions single choice(1)(item number:1577)A
35、method for System,out objects containing multiple outputdata,Where printin()method output A:1ine text and word wrapB:no line feedC:output two 1ines of text and line feedD:or more is wrongAnswer:A“Forty-first questions single choice(1)(item number:1478)The following concepts do not belong to the obje
36、ct orientedmethodA:objectB:inheritanceClass C:D:procedure callAnswer:D“Forty-second questions single choice(1)(item number:1574)The key word for defining long integer data is A:intB:byteC:doubleD:longAnswer:D“Forty-third questions single choice(1)(item number:1480)If a member variable in a class can
37、 only be accessed by the samepackage,use the following constraintsA:no access control charactersB:publicC:protectedD:finalAnswer:A“Forty-fourth questions single choice(1)(item number:1559)The main method of the application has the following statement,and the result of the output is Int a=12,14,2,4,6
38、;Int max=aO;For(int i=0;imax)Max=ai;)System,out.printin(max);A:12B:6C:14D:4Answer:C“Forty-fifth questions single choice(1)(item number:1575)Which of the following is the key word for Java?A:c o o lB:b o o lC:b o o le a nD:THISA n s w e r:C“F o r t y-s i x t h q u e s t i o n s s i n g le c h o i c e
39、 (1)(i t e m n u m b e r:1 5 4 9)Th e i n h e r i t a n c e r e la t i o n s h i p b e t w e e n c la s s e s o f t h e Ja v ala n g u a g e i s .A:m u lt i p le i n h e r i t a n c eB:s i n g le i n h e r i t a n c eC:t h r e a dD:c a n n o t i n h e r i tA n s w e r:B“F o r t y-s e v e n t h q u e
40、 s t i o n s s i n g le c h o i c e (1)(i t e m n u m b e r:1 5 4 5)W h i c h o f t h e f o llo w i n g i s a k e y w o r d?A:CLASSB:sizeofC:NULLD:importAnswer:D“Forty-eighth questions single choice(1)(item number:1487)The following description about inheritance is correctA:allows only a single inhe
41、ritance in JavaB:in Java,a class can only implement one interfaceC:in Java,a class cannot inherit a class and implement aninterface at the same timeThe single inheritance of D:Java makes the code unreliableAnswer:A“Forty-ninth questions single choice(1)(item number:1573)The keyword that defines doub
42、le precision data is A:intB:floatC:doubleD:charAnswer:CFiftieth questions single choice(1)(item number:1567)The main method of the application has the following statement,yThe value saved is Float x=5.5f;Int y;Y=(int)x+100;A:100B:105.5C:100.5D:105Answer:D“F ifty-first questions single choice(1)(item
43、 number:1474)The following is not the correct integer representation in JavaA:22B:0 x22C:022D:22HAnswer:D“Fifty-second questions single choice(1)(item number:1578)Following program segmentInt,sum=0,i=l;While(i=100)If(i%2,=0)Sum+=i;I+;System,out.printin(sum);Less than 100 of the outputA:even sumB:odd
44、 sumSum of C:natural numbersD:or more is wrongAnswer:B“Fifty-third questions single choice(1)(item number:1465)Suppose that MyProg.java has been compiled by the JDK compilerand generated by the application,Then execute the statement through the command line:Java,MyProg,I,like,tests,args0 in the main
45、 method areA:MyProgB:IC:likeD:testsAnswer:B“Fifty-fourth questions single choice(1)(item number:1475)The following definitions are known:String s=story”;thefollowing statement is legalA:s=books;B:char C=s 1;C:int len=s.length;D:String t=s.toLowerCase();Answer:D“Fifty-fifth questions single choice(1)
46、(item number:1473)The following is not a valid keyword in JavaA:constB:NULLC:falseD:thisAnswer:B“Fifty-sixth questions single choice(1)(item number:1485)The following is the meaning of anomaly”The syntax error of the A:programAn abnormal event that occurs during the compilation oroperation of a B:pr
47、ogramThe C:program defines good exception eventsD:program compilation errorAnswer:BFifty-seventh questions single choice(1)(item number:1546)Which of the following assignment statements is incorrect?A:float f=43.1;B:double d=7.5E12;C:float r=3.14;D:double f=6.2E12f;Answer:A“Fifty-eighth questions si
48、ngle choice(1)(item number:1560)The following InputStream classes Methods can be used toclose streamsA:skip()B:close()C:mark()Drreset()Answer:B“Fifty-ninth questions single choice(1)(item number:1464)The main method is the entry point for the execution of theApplication Java program,and the followin
49、g method of the mainmethod is legalA:public,static,void,main()B:public,static,void,main(String1 args)C:public,static,int,main(String ARG)Dipublic,void,main(String,arg)Answer:B Sixtieth questions single choice(1)(item number:1476)If x=1,y=2,z=3,then the value of the expression y+=z一/+xis A:3B:3.5C:4D
50、:5Answer:A“Sixty-first questions single choice(1)(item number:1479)The following statement is wrongThe A:interface is independent of the hierarchy of the classB:illustrates the methods implemented by the class through theinterfaceC:interfaces to objects through the interfaceThe D:interface is concer