月考javaSE部分.doc_第1页
月考javaSE部分.doc_第2页
月考javaSE部分.doc_第3页
月考javaSE部分.doc_第4页
月考javaSE部分.doc_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一、 单选(35小题共70.0分)1.下列代码的输出结果是:public class Yikes public static void go(Long n) System.out.println(Long ); public static void go(Short n) System.out.println(Short ); public static void go(int n) System.out.println(int ); public static void main(String args) short y = 6; long z = 7; go(y); go(z); A. LongLongB. ShortLongC. intLongD. intint2.下面不属于Java语言特点的是:A. 平台无关B. 面向对象C. 支持指针类型D. 垃圾回收机制3.下面关于final说法错误的是:( )A. final修饰类时,该类不能被继承。B. final修饰方法时,该方法不能被重写。C. 当引用到使用static final 修饰的常量时,将采用编译期绑定的方式。D. 当使用final和abstract共同修饰一个类时,final应至于abstract之前。4.下列代码的输出结果是( )。public static void main(String args) int one=new int4,6,8; int two=new int1,3,5,7,9; System.arraycopy(one, 1, two, 2, 2); System.out.println(Arrays.toString(two); A. 1, 3, 7, 4, 6B. 1, 3, 5, 7, 8C. 1, 3, 5, 6, 9D. 1, 3, 6, 8, 95.下列代码的输出结果是( )。public static void main(String args) Runnable r = new Runnable() public void run() System.out.print(Cat); ; Thread t = new Thread(r) public void run() System.out.print(Dog); ; t.start(); A. CatB. DogC. 没有任何输出D. 抛出运行时异常6.运行下面的程序:Calendar c = Calendar.getInstance();c.set(Calendar.YEAR, 2012);c.set(Calendar.MONTH, Calendar.SEPTEMBER);c.set(Calendar.DATE, 31);SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd);System.out.println(sdf.format(c.getTime();输出的结果是:( )。A. 2012-10-1B. 2012-10-01C. 2012-09-30D. 2012-9-307.下列代码中对象锁的使用效率最高的是:A. public class Foo private Object o1,o2; public synchronized void methodA()对o1进行操作 public synchronized void methodB()对o1进行操作 public synchronized void methodC()对o2进行操作 public synchronized void methodD()对o2进行操作B. public class Foo private Object lock = new Object(); private Object o1,o2; public void methodA()synchronized(lock)对o1进行操作 public void methodB()synchronized(lock)对o1进行操作 public void methodC()synchronized(lock)对o2进行操作 public void methodD()synchronized(lock)对o2进行操作C. public class Foo private Object lock = new Object(),lock2 = new Object(); private Object o1,o2; public void methodA()synchronized(lock)对o1进行操作 public void methodB()synchronized(lock)对o1进行操作 public void methodC()synchronized(lock2)对o2进行操作 public void methodD()synchronized(lock2)对o2进行操作D. public class Foo private Object lock = new Object(),lock2 = new Object(); private Object o1,o2; public void methodA()synchronized(lock)对o1进行操作 public void methodB()synchronized(lock2)对o1进行操作 public void methodC()synchronized(lock)对o2进行操作 public void methodD()synchronized(lock2)对o2进行操作8.下列代码编译和运行的结果是( )public class Foo public static void main(String args) java.util.List list = new java.util.ArrayList(); list.add(new B(); list.add(new C(); for (A a : list) a.x(); a.y(); interface A void x();class B implements A public void x() public void y() class C extends B public void x() A. 代码运行没有输出B. 运行时抛出异常C. 代码a.y();行,编译错误D. 代码java.util.List list = new java.util.ArrayList();行,编译错误9.请看下列代码的输出结果是: public class Bootchy int bootch; String snootch; public Bootchy() this(snootchy); System.out.print(first ); public Bootchy(String snootch) this(420, snootchy); System.out.print(second ); public Bootchy(int bootch, String snootch) this.bootch = bootch; this.snootch = snootch; System.out.print(third ); public static void main(String args) Bootchy b = new Bootchy(); System.out.print(b.snootch + + b.bootch); A. first second third snootchy 420B. third second first snootchy 420C. third first second snootchy 420D. first second first third snootchy 42010.下面关于数组的声明语句中,有编译错误的是:( )。A. int arr = new int1,2,3;B. int arr = null; arr = 1,2,3,4,5; C. int arr = new int1,2,3,4,5,6D. int arr = new int2;11.下列选项中,不能包含重复元素的容器是:( )。A. List B. ArrayList C. SetD. Collection12.下列代码的作用说法不正确的是:( )。class Card implements java.io.SerializableA. 开启序列化功能,使得Card类的对象可以存储到文件中B. 开启序列化功能,使得Card类的对象可以在网络上传输C. 使得Card类的子类的对象可以被序列化D. 导致Card的子类的对象不可以被反序列化13.如下方法声明中,错误的是( 。A. public void say() System.out.print(“Hi”); B. public void say() System.out.print(“Hi”); return; C. public int say() System.out.print(“Hi”); return; D. public int say() System.out.print(“Hi”); return 0; 14.下列选项中的类,能正确实现java.lang.Runnable接口和java.lang.Clonable接口的是( )。A. public class Session implements Runnable, Clonable public void run(); public Object clone();B. public class Session implements Runnable, implements Clonable public void run() / do something */ public Object clone() / make a copy */ C. public class Session implements Runnable, Clonable public void run() / do something */ public Object clone() /* make a copy */ D. public class Session extends Runnable, Clonable public void run() ; public Object clone();15.下列关于HashMap的方法描述正确的是: A. containsKey(Object key): 判断集合中是否包含指定的ValueB. containsValue (Object value): 判断集合中是否包含指定的KeyC. get(Object key):返回与参数Key所对应的Value对象,如果不存在则返回nullD. put(K key, V value):将Key-Value对存入Map,如果在集合中已经包含该Key,则操作将替换该Key所对应的Value,返回值为该Key当前(原来)所对应的Value(如果没有则返回null) 16.List类的对象list中的元素为:0, 1, 2, 3, 4, 5, 6, 7, 8, 9,现在想返回该list对象的子集合5,6,7,8,需要做的操作是:BA. list.subList(5, 8);B. list.subList(5, 9);C. list.subList(4, 8);D. list.subList(4, 9);17.给一个DateFormat的对象df和下列代码: public static void main(String args) DateFormat df = DateFormat.getDateInstance(); Date d = new Date(0L); String ds = December 15, 2004; 在处,根据ds的当前值改变d的值: A. d = df.parse(ds);B. d = df.getDate(ds);C. try d = df.parse(ds); catch(ParseException e) ;D. try d = df.getDate(ds); catch(ParseException e) ;18.请看下列程序的输出结果是: public class Item private String desc; public String getDescription() return desc; public void setDescription(String d) desc = d; public static void modifyDesc(Item item, String desc) item = new Item(); item.setDescription(desc); public static void main(String args) Item it = new Item();it.setDescription(Gobstopper); Item it2 = new Item();it2.setDescription(Fizzylifting);modifyDesc(it, Scrumdiddlyumptious); System.out.println(it.getDescription(); System.out.println(it2.getDescription(); A. ScrumdiddlyumptiousScrumdiddlyumptiousB. ScrumdiddlyumptiousFizzylifltngC. GobstopperScrumdiddlyumptiousD. GobstopperFizzylifting19.下列代码编译和运行的结果是: class SuperCalc protected static int multiply(int a, int b) return a * b; class SubCalc extends SuperCalc public static int multiply(int a, int b) int c = super.multiply(a, b); return c; public class TestSuper public static void main(String args) SubCalc sc = new SubCalc(); System.out.println(sc.multiply(3, 4); System.out.println(SubCalc.multiply(2, 2); A. 运行代码,但是没有输出B. 代码public static int multiply(int a, int b) 行,编译错误C. 代码int c = super.multiply(a, b);行,编译错误 D. 代码System.out.println(sc.multiply(3, 4);行,编译错误!20.查看如下代码:1. class HasStatic2. private static int x=100;3. public static void main(String args )4. HasStatic hs1=new HasStatic( );5. hs1.x+;6. HasStatic hs2=new HasStatic( );7. hs2.x+;8. hs1=new HasStatic( );9. hs1.x+;10. HasStatic.x-;11. System.out.println(“x=”+x);12. 13.对于此代码,下列描述中,正确的是( )。A. 5行不能通过编译,因为引用了私有静态变量B. 10行不能通过编译,因为x是私有静态变量C. 程序通过编译,输出结果为:x=103D. 程序通过编译,输出结果为:x=10221.请看下列代码:public interface A String DEFAULT_GREETING = Hello World; public void method1();现有接口B,是A接口的子接口,下列选择中B接口的声明正确的是: A. public interface B extends A B. public interface B implements A C. public interface B instanceOf A D. public interface B inheritsFrom A 22.下列代码编译和运行的结果是( )。public class A public void start() System.out.println(TestA); public class B extends A public void start() System.out.println(TestB); public static void main(String args) (A) new B().start(); A. 输出:TestAB. 输出:TestBC. 输出:TestA TestBD. 编译错误23.try里有一个return语句,那么紧跟在这个try后的finally里的代码执行的情况是:( )。A. 会执行,在return前执行B. 会执行,在return后执行C. 不会执行D. 会抛出异常24.下列关于线程的名字说法正确的是:( )。A. 不能人为的为线程设置名字B. Java规定所有的线程名字都是Thread=1形式的C. 可以使用Thread类的setName()方法为线程设置名字D. 默认情况下,线程无名字25.程序的执行结果是: public class Test public static void main(String args) String str1= new String(abc); String str2 = new String(abc); String str3=str1; if(str1.equals(str2) System.out.println(true); else System.out.println(false); if(str1=str3) System.out.println(true); else System.out.println(false); A. truetrueB. truefalseC. falsetrueD. false false26.分析如下语句,说法错误的是( )。A. break可用于跳出循环,当多层嵌套时,只用于跳出一层循环B. break即可以出现在循环语句中也可以出现在switch语句中C. continue可以用于跳出循环D. continue不能出现在switch语句中27.下列代码的输出结果是: String str1 = WhatisJava; String str2 = WhatisJava;System.out.print(str1 = str2);System.out.print(,);String str3 = new String(WhatisJava);System.out.println(str1 = str3); A.true,false B.false,false C.false,true D.true,true 28.下列代码编译和运行的结果是: public class A void process() throws Exception throw new Exception(); public static void main(String args) A a = new B(); cess(); class B extends A void process() System.out.println(B ); A. 输出:BB. 无输出C. B类的process方法处,出现编译错误D. 代码cess();行,出现编译错误29.下列代码的输出结果是: public static void main(String args) Queue queue = new LinkedList(); queue.offer(apple); queue.offer(orange); queue.offer(pear); queue.poll(); queue.poll(); queue.poll(); System.out.println(queue.poll(); A. appleB. orangeC. pearD. Null30.下面的代码用于对数组arr实现冒泡排序:for (int i = 0; i i; j-) if (arrj arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; for(int j=0;jarrj+1)int temp=arrj;arrj=arrj+1;arrj+1=temp;B. for (int j = arr.length - 1; j 0; j-) if (arrj arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; C. for (int j = i + 1; j arr.length; j+) if (arrj arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; D. for (int j = i; j arr.length; j+) if (arrj arrj - 1) int temp = arrj; arrj = arrj - 1; arrj - 1 = temp; isSwap = true; 31.题目代码实现的功能是:把放入到TreeSet集合中的Student进行排序,首先按照num升序,如果num相同,再按照name降序。请问插入代码1和插入代码2处应填入的代码分别是: public class SortStudent public static void main(String args) TreeSet set=new TreeSet(); set.add(new Student(19,tom); set.add(new Student(20,jessica); set.add(new Student(19,terry); class Student implements 插入代码1 private int num; private String name; public Student(int num,String name) =name; this.num=num;插入代码2A. Comparablepublic int compareTo(Object o) Student stu=null; if(o instanceof Student) stu=(Student)o; int result=this.numstu.num?1:(this.num=stu.num?0:-1); if(result=0) result=pareTo(); return result; B. Comparablepublic int compareTo(Object o) Student stu=null; if(o instanceof Student) stu=(Student)o; int result=this.numstu.num?1:(this.num=stu.num?0:-1); if(result=0) result=pareTo(); return result; C. Compartorpublic int compare(Object o) Student stu=null; if(o instanceof Student) stu=(Student)o; int result=this.numstu.num?1:(this.num=stu.num?0:-1); if(result=0) result=pareTo(); return result; D. Compartorpublic int compare(Object o) Student stu=null; if(o instanceof Student) stu=(Student)o; int result=this.numstu.num?1:(this.num=stu.num?0:-1); if(result=0) result=pareTo(); return result; 32.下列代码的输出结果是: public static void main(String args) String str=StringUtils.repeat(java, 3); System.out.println(str); A. jjjaaavvvaaaB. javaaC. jjjavaD. javajavajava33.下面的程序可以输出1100内前10个3的倍数: for (int i = 1, count = 0; i = 10) break;B. if (+count = 10) break;C. if (count+ = 10) continue;D. if (+count = 10) continue;34.下列属于不合法Java标识符的是( )。A. _avajB. 5saveC. AvajD. $8035.请看下列代码,出现错误的行是:( )public interface Cookie Cookie cookie=new Cart (小面包,盼盼);public class Cart implements Cookie private String name; private String production; public Cart(String name,String production) =name; duction=production; public void smell() cookie =new Cart(蛋黄派,达利园); A. 第2行B. 第4行C. 第11行D. 第12行二、 多选(5小题共10.0分)1.下列异常类是RuntimeException的子类的是:( )。A. ArrayIndexOutOfBoundsExceptionB. NullPointerExceptionC. NumberFormatExceptionD. ClassNotFoundException2.以下创建线程的方式正确的是: A. class Runner implements Runnable public void run() 线程体 public static void main(String args) Runner r = new Runner(); Thread t = new Thread(r); t.start(); B. class Runner implements Runnable public void run() 线程体 public static void main(String args) Runner t = new Runner(); t.start(); C. class Runner extends Thread public void run() 线程体 public static void main(String args) Thread t = new Runner(); t.start();D. class Runner public static void main(String args) Thread t = new Thread() public void run() 线程体 ; t.start(); 3.在Java语言中,下列说法正确的是:( )。A. StringBuffer和StringBuilder的区别在于:StringBuffer是线程安全的而StringBuilder不是。B. String是不可变对象,而StringBuffer中封装的字符串数据是可以动态改变的。C. 判断两个StringBuilder对象的字符序列是否相同,可以调用其equlas方法进行比较。D. String的重写了equals方法,重写的逻辑是:字符序列相同的String对象equals方法返回true。4.下列逻辑表达式,值为false的是( )。A. abc,bcd,def,efg,.split(,+).length = 4;B. 1st456.matches(da-z&et2,80-9+);C. abcdefghijklmnopqrstuvwxyz.substring(5,26).length() = 20;D. whatisjava.equals(null);5.在Java语言中,下列说法正确的是( )。A. 一个接口可以继承多个接口B. 一个类可以继承多个类C. 一个类可以实现多个接口D. 一个类可以有多个子类 三、 完形填空(2小题共20.0分)1.阅读理解 public class A public A() System.out.print(A ); public A(String s) System.out.print(s); public void fun() System.out.println(A.fun(); public class B extends A public B() System.out.print(B ); public B(String s) super(s); public void fun() System.out.println(B.fun(); public void sun() System.out.println(B.sun(); public static void Main() A a = new B(); a.fun(); (1).下列关于上述代码中构造方法的描述,错误的是( )。A. 实例化对象 a 时,将默认调用父类的无参构造方法B. 类 B中使用 super 关键字,是为了调用父

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论