版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、JAVA WRITTEN EXAMINATION第一部分第一部分 Java根底根底1.测试题测试题Q、假设当前系统下的JDK安装目录为C:Program FilesJavajdk1.6.0_12,配置相关的环境变量。Q、编写一个Application,在屏幕上显示如下的信息:Welcome To IBM-ETP,文件名:Welcome.javaA、 变量名:Path 变量值:. .;C:Program FilesJavajdk1.6.0_04bin变量名:classpath 变量值:.;C:Program FilesJavajdk1.6.0_04lib变量名:JAVA_HOME 变量值:C:P
2、rogram FilesJavajdk1.6.0_04A、 public class Welcome public static void main String args System.out.println(“Welcome To IBM-ETP); Q、一个.java源文件中能否可以包括多个类?有什么限制?A、 可以。必需只需一个类名与文件名一样有,且只需一个是公共类Q、部分变量和成员变量的各自特点。Q、 short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?A、部分变量:变量可以定义为只在某个程序块或只在方法体内部有效,这
3、种类型的变量通常被称为“部分变量,部分变量只是相应的方法体内或程序块内有效部分变量在运用之前,必需先初始化成员变量(属性/全局变量):不在方法体内也不在程序块中的变量,成员变量经过对象援用成员变量假设没有初始化,在运用时,系统将会自动赋一个默许的初始值A、错,在Java中,整数的字面值为int型,即1的数据类型为int,在进展s1 + 1 的运算时,先进展数据类型转换,把short型的s1转换成int型,在进展加运算,这样导致的结果是s1 + 1运算后的数据类型为int型,而int的型的数值不能赋给short型变量,正确的表达式为:s1 = (short)(s1 + 1)Q、 char型变量中
4、能不能存贮一个中文汉字?为什么? Q、 heap和stack有什么区别?A、可以定义成为一个中文的,由于java中以unicode编码,一个char占2个字节,而一个中文也是占2个字节,所以放一个中文是没问题的A、栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进展处置。堆是栈的一个组成元素。Q、 String是最根本的数据类型吗?并请写出一切的原始数据类型?A、不是,根本类型:boolean、char、int、short、long、float、double、byte Q、Java有没有goto?A、java中的保管字,如今没有在java中运用。Q、写出下面程序的输
5、出结果: class Something public static void main(String args) int i = 0;if (false & (i = i + 1) 1) System.out.println(i);System.out.println(i);if (false & (i = i + 1) 1) System.out.println(i);System.out.println(i); A、01Q、设x=2 ,那么表达式(x+)*3的值是? A、6Q、 String类和StringBuffer类的主要差别是什么?写出相互间转换所运用的函数? A、字符串常量:创建
6、以后不需求改动的,在Java中,String类用于存储和处置字符串常量字符串变量:创建以后,需求对其进展改动的,在Java中,StringBuffer类用于存储和操作字符串变量。String str = abc;StringBuffer strBuffer = new StringBuffer(abc);strBuffer = new StringBuffer(str);str = strBuffer.toString();str = new String(strBuffer);Q、代码如下:String foo = ABCDE; foo.substring(3); foo.concat(XY
7、Z);System.out.println(foo);写出结果:A、 ABCDEQ、 Java编程言语为八个原始数据类型,请填写下表。分类描述类型名字节数逻辑型布尔型 boolean不确定文本型字符型 char2整数型字节型 byte1短整型 short2整型 int4长整型 long8浮点型单精度浮点型 float4双精度浮点型 double8Q、下面哪些声明是合法的? Along i = 4990 Bint i = 4LCfloat f = 1.1 Ddouble d = 34.4Q、如下哪些不是java的关键字 Ajava BNULL Cfalse DthisQ、 main方法是Java
8、 Application程序执行的入口点,关于main方法的方法头以下哪项是不合法的( ) A. public static void main () B. public static void main (String args)C. public static int main (String args) D. public void main (String args)Q、以下哪些是合法的整型变量声明 (A)int $x; (B) int 123; (C) int _123; (D) int #dim; (E) int %percent; (F) int *divide; (G) int
9、 central_sales_region_Summer_2019_gross_sales; ACGABABCDADQ、设float x=1,y=2,z=3,那么表达式y+=z-/+x的值是 A. 3.5 B. 3 C. 4 D. 5Q、假设val是整型变量,下面 说法不正确。if (val 4) System.out.println(Test A); else if (val 9) System.out.println(Test B); else System.out.println(Test C);A.val = 0输出“Test C B.val介于0到4 之间输出“Test CC.val
10、 = 14输出“Test B D.val = 5 输出“Test AACQ、下面哪个表达式可用得到x和y的最大值( )A) xy?y:x B) xy?(x+y):(x-y) D) x=y?y:x;BQ、有下面程序,语句a=a+1执行的次数是 。public class Something public static void main(String args) int x = 8, a = 1;do a = a + 1; while (x 0);A.0 B.1 C.无限次 D.有限次CQ、以下循环体的执行次数是 int i, j;for (i = 0, j = 1; i = j + 1; j-
11、) i = i + 2;A.3 B.2 C.1 D.0CQ、下面代码输出结果是 。 int i = 0, s = 0; do if (i % 2 = 0) i+; continue;i+; s = s + i; while (i 7);System.out.println(s);A.16 B.12 C.28 D.21BQ、定义变量如下: char c=w; int i=8; long L=15; float f=8.9f;以下赋值语句正确的选项是( )A) i=c+i; B) c=c+i; C) L=f+L; D) f=i+L+f;ADQ、阅读以下代码,i值为 时输出结果中不包括“Test2
12、switch (i) default: System.out.println(no match);case 1:System.out.println(Test1);case 2:case 3:System.out.println(Test2);break;case 4:System.out.println(Test3);break;A. 0 B. 1 C. 2 D. 3 E. 4EQ、关于下面代码片段,说法正确的选项是 int a = 8, b = 9;if (a = b) System.out.println(true); else System.out.println(false);A.
13、输出true B.输入false C.无输出 D.编译错误DQ、以下语句执行后,变量a、c的值分别是 ( )int x = 182;int a, c;c = x / 100;a = x % 10;A) 1,2 B) 2,1 C) 1.82, 2 D) 100,82 BQ、下面程序中,while循环的循环次数是 public static void main(String args) int i = 0;while (i 10) if (i 1; n-) s = s + 1 / n;System.out.println(s);程序运转后,输出结果错误,导致程序出错的是 A.s = 1.0 B.
14、for(n=10;n1;n-) C. s = s + 1 /n D. System.out.println(s);CQ、以下语句序列执行后,k 的值是( )int x = 2, y = 5, k = 0;switch (x % y) case 0:k = x + y;break;case 1:k = x - y;break;case 2:k = x * y;break;default:k = x / y;break;System.out.println(k);A) 2 B) 5 C) 10 D) 0 CQ、阅读代码片段,下面 代码导致程序出错public class Something pub
15、lic static void main(String args) int count; / 第1行int x = new int10; / 第2行for (int i = 0; i = 3 Bs3 = “x;Cint i = s.length(); Ds = s + 10CD Q、阅读下面代码片段,输出结果是 StringBuffer sb = new StringBuffer(Hello );String t = MY ;t = t + FRIEND;sb.append(t);System.out.println(sb.toString().toLowerCase(); A. my fri
16、end hello B. Hello MY FRIEND C. MY FRIEND Hello D. hello my friendDQ、String s1 = new String(phenobarbital); 经过下面代码之后, String s2 = s1.substring(3, 5); s2的值是 A.null B.eno C.enoba D.noD Q、下面 不是String对象合法的方法。A. equals(String) B.trim() C. append() D.indexOf()C Q、下面 正确创建包含5个字符串的数组A.String a = new String5;
17、for (int i = 0; i 5; i+) ai = ;B.String a = new String ;a = ,;C. String a = ,;D. String a = new String5 ,;E. String a5 = ,ACQ、下面说法中正确的选项是 A. 调用String对象的length()方法可获得字符串长度B. 调用String对象的length属性可获得字符串长度C. 调用数组变量的length()方法可以获得数组的长度D. 调用数组变量的length属性可以获得数组的长度AD Q、阅读下面代码,运转输出 String space = ;String comp
18、osite = space + hello + space + space;composite.concat(world);String trimmed = composite.trim();System.out.println(trimmed.length();A.5 B.6 C. 8 D.13Q、以下数组的初始化正确的选项是 A. int socre=new int5 B. int score=new int90,12,34,77,56C. int score=new int590,12,34,77,56 D. int score=90,12,34,77,56AABQ、运用程序的main方
19、法中有以下语句,那么输出的结果是 ( )。int x = 122, 33, 55, 678, -987 ;int max = x0;for (int i = 1; i max)max = xi;System.out.println(max);A) 678 B) 122 C) -987 D) 33A Q、 given the following variables:char c = c;int i = 10;double d = 10;long l = 1;String s = hello;Which of the following will compile without error? (
20、)A)c=c+i; B)s+=i; C)i+=s; D)c+=s;BQ、 What will happen when you attempt to compile and run this code? ( )public class Something public static void main(String argv) System.out.println(hello cruel world);A) The compiler will complain that main is a reserved word and cannot be used for a classB) The co
21、de will compile and when run will print out hello cruel worldC) The code will compile but will complain at run time that no constructor is definedD) The code will compile but will complain at run time that main is not correctly definedD Q、 Which of the following will compile correctly?( )A) short my
22、short = 99s;B) string name = excellent tutorial mr green;C) char c = 17c;D) int z = 15;DQ、 What will happen when you attempt to compile and run the following code? ( )int output = 10;boolean b1 = false;if (b1 = true) & (output += 10) = 20) System.out.println(we are equal + output); else System.out.p
23、rintln(not equal! + output);A) compile error, attempting to peform binary comparison on logical data typeB) compilation and output of we are equal 10C) compilation and output of not equal! 20D) compilation and output of not equal! 10D Q、given the following main method in a class called HelloWorld an
24、d a command line ofjava HelloWorld one two What will be output? ( )public static void main(string bicycle)System.out.println(bicycle0);A) none of these options B) HelloWorld C) one D) twoC Q、what will happen when you attempt to compile and run this code?( )public class mymainpublic static void main(
25、String argv) System.out.println(hello cruel world);A) the compiler will complain that main is a reserved word and cannot be used for a classB) the code will compile and when run will print out hello cruel worldC) the code will compile but will complain at run time that no constructor is definedD) th
26、e code will compile but will complain at run time that main is not correctly definedD Q 、 you want to find out the value of the last element of an array. you write the following code. what will happen when you compile and run it.? ( )public class myarpublic static void main(String argv) int i = new
27、int5; System.out.println(i5); A) an error at compile time B) an error at run timeC) the value 0 will be output D) the string null will be outputBQ 、 以下程序段执行后t5的结果是 int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 t2 ? t1 : t2+ t1;t5 = t4 t3 ? t4 : t3;A) 8 B) 20 C) 11 D) 9Q 、设 a, b, c, d 均为 int 型的变量,并已赋值,
28、以下表达式的结果属于非逻辑值的是 A) a!=b & c%d =c+dQ、以下的选项中能正确表示Java言语中的一个整型常量的是 A) 12. B) -20 C) 1,000 D) 4 5 6Q 、以下选项中,合法的赋值语句是 A) a = = 1; B) + i; C) a=a + 1= 5; D) y = int ( i );Q 、假设所用变量都已正确定义,以下选项中,非法的表达式是 A) a != 4|b=1 B) a % 3 C) a = 1/2 D) A + 32Q 、假设有定义int a = 2;那么执行完语句a += a -= a * a; 后,a的值是 A) 0 B) 4 C)
29、 8 D) 4Q 、在Java言语中,逻辑常量只需true 和 _ 两个值。Q 、 Java言语中的浮点型数据根据数据存储长度和数值精度的不同,进一步分为float和 _两种详细类型。Q 、以下字符常量中不合法的是 A) | B) C) n D) 我Q 、 Java言语是 A.面向问题的解释型高级编程言语 B.面向机器的低级编程言语C.面向过程的编译型高级编程言语 D.面向对象的解释型高级编程言语 Q 、以下的变量定义中,错误的选项是 A) int i; B) int i=Integer.MAX_VALUE; C) static int i=100; D) int 123_$; Q 、以下的变
30、量定义语句中,合法的是 A) float $_*5= 3.4F; B) byte b1= 15678;C) double a =Double. MAX_VALUE; D) int _abc_ = 3721L; Q 、 假设以下变量均已正确定义并赋值,下面符合Java言语语法的语句是 A) b = a!=7 ; B) a = 7 + b + c=9;C) i=12.3* % 4; D) a = a + 7 = c + b;第一部分第一部分 Java根底根底2.面试题面试题Question 1:String是最根本的数据类型吗是最根本的数据类型吗?Answer 1:不是不是Question2 :i
31、nt 和和 Integer 有什么区别有什么区别?Answer 2:Question3 :String 和和StringBuffer的区别的区别?Answer 3:Question 4:&和和&的区别的区别?Answer 4:Question5:heap和和stack有什么区别有什么区别(从数据构造层面分析从数据构造层面分析)?Answer 5:栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方:栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进展处置。堆是栈的一个组成元素。式进展处置。堆是栈的一个组成元素。Question6 :GC是什么是
32、什么? 为什么要有为什么要有GC?Answer 6:GC是渣滓搜集的意思是渣滓搜集的意思Gabage Collection,内存处置是编程人员容易出现问题的地内存处置是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至解体,方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至解体,Java提供的提供的GC功能可以自动功能可以自动监测对象能否超越作用域从而到达自动回收内存的目的,监测对象能否超越作用域从而到达自动回收内存的目的,Java言语没有提供释放已分配内存的显示言语没有提供释放已分配内存的显示操作方法。操作方法。Question 7:short s1 = 1;
33、 s1 = s1 + 1;有什么错有什么错? short s1 = 1; s1 += 1;有什么错有什么错?Answer 7:short s1 = 1; s1 = s1 + 1; s1+1运算结果是运算结果是int型,需求强迫转换类型型,需求强迫转换类型short s1 = 1; s1 += 1;可以正确编译可以正确编译+=运算符无类型转换问题!运算符无类型转换问题!Question8:Math.round(11.5)等於多少等於多少? Math.round(-11.5)等於多少等於多少?Answer 8:Math.round(11.5)=12Math.round(-11.5)=-11Ques
34、tion9:String s = new String(xyz);创建了几个创建了几个String Object? Answer 9:两个对象,一个是:两个对象,一个是xyz,一个是指向一个是指向xyz的援用对象的援用对象sQuestion 10:Java有没有有没有goto?Answer 10:java中的保管字,如今没有在中的保管字,如今没有在java中运用。中运用。Question11:Math.round(11.5)等於多少等於多少? Math.round(-11.5)等於多少等於多少?Answer 11:Math.round(11.5)=12Math.round(-11.5)=-11
35、Question12:String s = new String(xyz);创建了几个创建了几个String Object? Answer 12:两个对象,一个是:两个对象,一个是xyz,一个是指向一个是指向xyz的援用对象的援用对象sQuestion 13:数组有没有数组有没有length()这个方法这个方法? String有没有有没有length()这个方法这个方法?Answer 13:数组没有数组没有length()这个方法,有这个方法,有length的属性。的属性。String有有length()这个方法。这个方法。Question14:swtich能否能作用在能否能作用在byte上,
36、能否能作用在上,能否能作用在long上,能否能作用在上,能否能作用在String上上?Answer 14:switchexpr1中,中,expr1是一个整数表达式。因此传送给是一个整数表达式。因此传送给 switch 和和 case 语句的参数应该是语句的参数应该是 int、 short、 char 或者或者 byte。long,string 都不能作用于都不能作用于swtich。Question15:用最有效率的方法算出用最有效率的方法算出2乘以乘以8等於几等於几?Answer 15:2 3Question 16:两个对象值一样两个对象值一样(x.equals(y) = true),但却可有不同的,但却可有不同的hash code,这句话对不对,这句话对不对?Answer 16:不对,有一样的不对,有一样
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 47660-2026温室气体产品碳足迹量化方法与要求水力发电
- GB/T 47652-2026温室气体产品碳足迹量化方法与要求光伏发电
- 某玻璃厂能源消耗管理细则
- 某造船厂起重作业细则
- 2026秋人教PEP三年级上册英语Unit1 Hello 同步一课一练(分层基础+提升)
- 油库储存企业隐患排查治理管理制度
- 纺织厂布料检验办法
- 造纸厂纸张平整制度
- 某服装厂设备采购办法
- 橡塑厂废品回收准则
- 2025年上海市青浦区社区工作者招聘笔试试题及答案详解
- 2026辽宁沈阳盛京金控投资集团有限公司招聘4人参考题库带答案详解AB卷
- 2026江苏苏州工业园区苏相合作区管理委员会机关人员招聘9人模拟试卷含答案详解(夺分金卷)
- 2026年职业技能大赛CAD机械设计技能竞赛理论考试重点试题库
- 信阳市国企招聘考试真题及答案
- 常州市房屋租赁合同(常州市2021版)
- 高支模工程专项施工方案(附图及计算书)
- GA/T 1799-2021保安安全检查通用规范
- 组织内外部环境识别表
- 2022年中国航天科技集团有限公司校园招聘笔试模拟试题及答案解析
- 毒理学基础名词解释与问答题
评论
0/150
提交评论