《java》模拟试题及答案

上传人:第*** 文档编号:34949018 上传时间:2018-03-04 格式:DOC 页数:15 大小:92.50KB
返回 下载 相关 举报
《java》模拟试题及答案_第1页
第1页 / 共15页
《java》模拟试题及答案_第2页
第2页 / 共15页
《java》模拟试题及答案_第3页
第3页 / 共15页
《java》模拟试题及答案_第4页
第4页 / 共15页
《java》模拟试题及答案_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《《java》模拟试题及答案》由会员分享,可在线阅读,更多相关《《java》模拟试题及答案(15页珍藏版)》请在金锄头文库上搜索。

1、 1 / 15 一、选择题 1欲构造 ArrayList 类的一个实例,此类继承了 List 接口,下列哪个方法是正 确的 ( B ) A、 ArrayList myList=new Object() ; B、 List myList=new ArrayList() ; C、 ArrayList myList=new List() ; D、 List myList=new List() ; 2paint()方法使用哪种类型的参数 ( A ) A、 Graphics B、 Graphics2D C、 String D、 Color 3指出正确的表达式 ( C ) A、 byte=128; B、

2、Boolean=null; C、 long l=0xfffL; D、 double=09239d; 4指出下列程序运行的结果 ( B ) 字符串不能变,数组可以变 public class Example String str=new String(“good“); charch=a,b,c; public static void main(String args) Example ex=new Example();exchange(exstr,exch); Systemoutprint(exstr+“ and “); Sytemoutprint(exch); 2 / 15public voi

3、d change(String str,char ch) str=“test ok“; ch0=g; A、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5运行下列程序, 会产生什么结果 ( A ) public class X extends Thread implements Runable 应该是 Runnable 少了个 npublic void run() Systemoutprintln(“this is run()“); public static void main(String args)

4、Thread t=new Thread(new X(); tstart(); A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 3 / 15 6要从文件“ filedat“文件中读出第 10 个字节到变量 C 中,下列哪个方法适合? ( D ) A、 FileInputStream in=new FileInputStream(“filedat“); inskip(9); int c=inread(); B、 FileInputStream in=new FileInputStream(“filedat“); inskip(10); i

5、nt c=inread(); C、 FileInputStream in=new FileInputStream(“filedat“); int c=inread(); D、 RandomAccessFile in=new RandomAccessFile(“filedat“); inskip(9); int c=inreadByte(); 7容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小 的变化而改变? ( B ) 布局管理器 FlowLayout Panel 的默认布局管理器BorderLayout 分为东西南北中五个区域,每个区域最多一个组 件GridLayout 网

6、格布局,将容器分为很多个网格 A、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8给出下面代码: public class Person static int arr = new int10; 4 / 15public static void main(String a) Systemoutprintln(arr1); 那个语句是正确的? ( C ) A、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C 、输出零; D、 输出空。 9下列那个是反斜杠的正确表示?( A ) 在JAVA 中“”是转义字符,所以要表示一

7、个字符串“”就要用“” 两个 连续的转义字符表示一个字符串“” A、 B、 * C、 D、 10下列哪些语句关于内存回收的说明是正确的? ( B ) A、 程序员必须创建一个线程来释放内存; B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11下列代码哪几行会出错: ( C) 1) public void modify() 2) int I, j, k; 3) I = 100; 4) while ( I 0 ) 5 / 15 5) j = I * 2; 6) Systemoutprintln (“ The value o

8、f j is “ + j ); 7) k = k + 1; k 未赋值 8) I-; 9) 10 A、 line 4 B、 line 6 C、 line 7 D、 line 8 12MAX_LENGTH 是 int 型 public 成员变量, 变量值保持为常量 100,用简短 语句定义这个变量。 ( D ) A、 public int MAX_LENGTH=100; B、 final int MAX_LENGTH=100; C、 final public int MAX_LENGTH=100; D、 public final int MAX_LENGTH=100 13给出下面代码:1) cl

9、ass Parent 2 private String name; 3 public Parent() 4 5) public class Child extends Parent 6 private String department; 7 public Child() 6 / 158 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent(); 11 12 那些行将引起错误? ( D ) A、 第 3 行 B、 第 6 行 C、 第 7 行 D、

10、 第 8 行 14类 Teacher 和 Student 是类 Person 的子类; Person p; Teacher t; Student s; /p, t and s are all non-null if(t instanceof Person) s = (Student)t; 最后一句语句的结果是: (C) A、 将构造一个 Student 对象; B、 表达式是合法的; C、 表达式是错误的; D、 编译时正确,但运行时错误。 15给出下面代码段 1) public class Test 2) int m, n; 3) public Test() 4) public Test(i

11、nt a) m=a; 5) public static void main(String arg) 7 / 156) Test t1,t2; 7) int j,k; 8) j=0; k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) 12) 哪行将引起一个编译时错误? ( D ) A、 line 3 B、 line 5 C、 line 6 D、 line 10 16对于下列代码: 1) class Person 2) public void printValue(int i, int j) / 3) public void printValue(i

12、nt i)/ 4) 5) public class Teacher extends Person 6) public void printValue() / 7) public void printValue(int i) / 8) public static void main(String args) 9) Person t = new Teacher(); 10) tprintValue(10); 11) 第 10 行语句将调用哪行语句?( D ) 8 / 15 A、 line 2 B、 line 3 C、 line 6 D、 line 7 17哪个关键字可以抛出异常? ( C ) A、

13、 transient B、 finally C、 throw D、 static 18Main()方法的返回类型是: ( B ) A、 int B、 void C、 boolean D、 static 19 ( C )布局管理器使容器中各个构件呈网格布局,平局占据容器空间。 A、 FlowLayout B、 CardLayout C、 GridLayout D、 BorderLayout 20对于下列代码: public class Parent public int addValue( int a, int b) int s; s = a+b; return s; class Child e

14、xtends Parent 下述哪些方法可以加入类 Child? ( D ) 子类继承父类时重写,参数列表不变 重载是发生在一个类时,参数列表变 A、 int addValue( int a, int b )/ do something 9 / 15 B、 public void addValue (int a, int b )/ do something C、 public int addValue( int a )/ do something D、 public int addValue( int a, int b )throws MyException /do something 二、填空 1如果一个 java 源程序文件中定义有 4 个类,使用 sun 公司的 JDK 编译器 javac 编译该源程序文件将产生_4 个文件名与类名相同扩展名为_ .class_的字节码文件。 2Java 中所有类都是类 _ Object _的子类。 3请填出在 javalang 包中与下列基本数据类型相对应的封装类: float:javalangFloat, char:_java.lang.Char, boolean: java.lang. Boolean _ _。 4被关键字_private

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 教学课件 > 初中课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号