




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JAVA测试试卷 (2007年)一、选择题(每题3分,共30分)1、关于JAVA程序的构成及存储要求,下列说法中正确的是 (C )。(A) JAVA程序由一个或多个public类构成,存盘时文件名必须以其中一个public类的类名命名。(B) JAVA程序必须包含一个public类,存盘时文件名必须以public类的类名命名。(C) JAVA程序最多包含一个public类,若有public类,则存盘时文件名必须以public类的类名命名,否则以其他任何一个类的类名命名即可。(D) JAVA程序由一个或多个public类构成,存盘时文件名以程序中任何一个类的类名命名即可。2、下列代码编译后不会出现警告或错误的是 ( B )。(A) char c = a; (B) byte b = 255; (C) float c = 10.0; (D) double d = 1.0f;3、下面这段代码编译时会发生什么情况( A )。public class MyClass public static void main(String args) amethod(args);public void amethod(String args) System.out.println(args);System.out.println(args1);(A) error, cant make static reference to void amethod(B) error, method main not correct(C) error, array must include parameter (D) amethod must be declared with String4、执行下述命令的输出结果为 ( D)。java myprog good morningpublic class myprog public static void main(String args) System.out.println(args2);(A) myprog (B) good (C) morning (D) Exception raised: java.lang.ArrayIndexOutOfBoundsException: 25、下列关于数组的声明与创建语句中,正确的是( C )。(A) int a10; a= new int10; (B) float b10 = new float ;(C) char c = new char10; (D) byte b10; b = new byte ;6、下述程序的输出结果为 ( A )。class Cal private int x, y, z; int cal() z = x*y; return z; public class exam public static void main(String args) Cal tmp = new Cal(); tmp.x = 10; tmp.y = 20; System.out.print(tmp.cal(); (A) 私有变量访问错误,不能通过编译 (B) 200 (C) 30 (D) 107、下述程序正确的是( D )。(A) public class A public static void main(String args) short snum1, snum2, snum3; snum1 = 10; snum2 = 20; snum3 = snum1 + snum2;/类型转换 (B) public class B_1 public void method() public class B_2 extends B_1private void method() /继承问题(C) public class C public int method() return 0;public String method() return “neu”;/函数重载(D) public class D public static void main(String args) final int a = 100; final int b; b = 200;8、下述程序的输出结果为 ( D )。class Cube public int length; public static int width, height; Cube() length = width = height = 10; void setValue(int length, int width, int height) this.length = length; this.width = width; this.height = height; public class StaValue public static void main(String args) Cube v1 = new Cube(); Cube v2 = new Cube(); Cube v3 = new Cube(); v2.setValue(20, 20, 20); v3.setValue(30, 30, 30); System.out.println(v1.length + + v2.width + + v3.height); (A) 10 20 30 (B) 30 30 30 (C) 20 20 30 (D) 10 30 309、下述程序的输出结果为 ( B )。public class StringTest public static void main(String args) String s1 = new String (we are students); String s2 = new String (we are students); String s3 = new String (This example is about substring); String s4 = new String (); s4 = s3.substring(5, 14); System.out.print(s1.length(); System.out.print(s1= =s2); System.out.print(s2.indexOf(are); System.out.print(s4); (A) 16 false 3 example is (B) 15 false 3 example i(C) 15 true 4 example i (D) 16 true 4 example is10. 下面这段代码编译和运行时会发生什么情况 ( C )。abstract class MineBase abstract void amethod();static int i;public class Mine extends MineBase public static void main(String args) int ar = new int5;for(int i=0; i ar.length; i+)System.out.println(ari);(A) 将0到4打印出来 (B) Error: ar is used before it is initialized (C) Error: Mine is not abstract and does not override abstract method amethod () in MineBase(D) Array IndexOutOfBoundes Error二、填空题(每题3分,共30分)1、设jdk已安装至C盘的jdk1.5.0目录,则Windows系统的环境变量PATH应设为_ C:jdk1.5.0bin ,CLASSPATH应设为_ C:jdk1.5.0lib _。JAVA源程序文件的扩展名为_.java_,编译后生成的字节码文件的扩展名为_.class_。2、下述程序的输出结果为 _23_。public class ScopeTest public int i = 1;public void firstMethod() int i = 7, j = 8;this.i = i + j;secondMethod(this.i);public void secondMethod(int i) int j = 8;this.i = i + j;public static void main(String args) ScopeTest obj = new ScopeTest(); obj.firstMethod(); System.out.println(obj.i);3、下述程序的输出结果为 _39_。class MathTwo static int add(int a, int b) return a + b; static int sub(int a, int b) return a - b; static int mul(int a, int b) return a * b; public class MathTwoTest public static void main(String args) int x = 8, y = 5, z; z = MathTwo.mul(MathTwo.add(x, y), MathTwo.sub(x, y); System.out.print(z); 4、下述程序的输出结果为_1981-12-10_。public class MyDatepublic int year;public int month;public int day;public MyDate(int y, int m, int d) year = y; month = m; day = d; public void setYear(int y) year = y; public void setMonth(int m) month = m; public void setDay(int d) day = d;public class ChangeDate public static void changeDate_1(MyDate mydate) mydate = new MyDate(1979, 2, 3); public static void changeDate_2(MyDate mydate) mydate.setMonth(12); public static void main(String args) MyDate date = new MyDate(1981, 9, 10); changeDate_1(date); changeDate_2(date); System.out.println(date.year + “-“ + date.month + “-“ + date.day);5、下述程序的输出结果为_8000_。class Cube int length=10, width=20, height=30;Cube() length = width = height = 20; public void setValue(int length, int width, int height) this.length = length; this.width = width; this.height = height; public int volume() return length * width * height; public class CubeInstance public static void main(String args) Cube v1 = new Cube(); System.out.print(v1.volume(); 6、下述程序的输出结果为_ Invocation child class _。public class OverridingParent public void method() System.out.println(Invocation parent class);public class OverridingChild extends OverridingParentpublic void method() System.out.println(Invocation child class);public static void main(String args) OverridingChild t = new OverridingChild();t.method();7、下述程序的输出结果为_ Child getInfo invoked _。class Parent public String getInfo() return “Parent getInfo invoked”;class Child extends Parent public String getInfo() return “Child getInfo invoked”;public class VirtualMethod public static void main(String args) Parent p = new Child(); System.out.println(p.getInfo(); 8、下述程序的输出结果为_1977-8-16_。public class ParentConstructor public int year; public int month; public int day; public static final int default_month = 2; public static final int default_day = 16; public ParentConstructor(int y, int m, int d) year = y; month = m; day = d; public ParentConstructor(int y) this(y, default_month, default_day); public ParentConstructor(int y, int m) this(y, m, default_day); public class ChildConstructor extends ParentConstructor public ChildConstructor(int h) super(1977, 8); public static void main(String args) ChildConstructor t = new ChildConstructor(12); System.out.println(t.year + - + t.month + - + t.day); 9、下述程序的输出结果为_false false false true_。public class EqualsTest public static void main(String args) MyDate day1 = new MyDate(3, 2, 2002); MyDate day2 = new MyDate(3, 2, 2002); System.out.println(day1 = = day2); System.out.println(day1.equals(day2); String str1 = new String(A String); String str2 = new String(A String); System.out.println(str1 = = str2); System.out.println(str1.equals(str2); 10、下述程序的输出结果为_30 10 20_。class A int i, j; void setA(int i, int j) this.i = i; this.j = j; class B extends A int j, k; void setB(i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025广西柳州市柳江中学参加广西师范大学2025届研究生毕业生春季专场双选会招聘11人模拟试卷及一套完整答案详解
- 2025贵州金沙县总工会招聘社会工作者笔试备考试题及答案解析
- 2025年呼吸内科常见病症诊疗能力检测答案及解析
- 2025年呼吸内科呼吸困难急救处理考核试卷答案及解析
- 2025年血液科实验室常见检测结果解读考核答案及解析
- 2025年风湿免疫科疾病诊断与治疗操作规范性考核答案及解析
- 城市道路地下空洞病害演化机理深度剖析与防治策略研究
- 建筑材料采购合同风险管控
- 2025年G通信技术在物联网设备连接中的可行性研究报告
- 2025年数字货币在支付领域应用企业经营风险预警可行性报告
- 【幼儿园自主游戏开展现状、问题及改进建议研究6500字(论文)】
- 2025年湖南株洲市工会社会工作者招聘30人考试笔试试卷【附答案】
- 2025年9月 基孔肯雅热疫情防控工作的经验总结报告
- 第2课《中国人首次进入自己的空间站》教学设计-统编版语文八年级上册
- 新能源销售基础知识培训课件
- 上海婚恋婚介培训课件
- 植物的身体说课课件
- 烧结工艺培训课件
- 外宾参观活动方案
- 1.4理解与感知1812序曲课件-高中音乐湘教版必修音乐鉴赏
- 乡镇卫生院管理制度
评论
0/150
提交评论