ImageVerifierCode 换一换
格式:DOC , 页数:16 ,大小:73.01KB ,
资源ID:135649      下载积分:5 金币
已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  
下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(达内JSD1412第一次月考试题及答案.doc)为本站会员(奥沙丽水)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(发送邮件至doc331@126.com或直接QQ联系客服),我们立即给予删除!

达内JSD1412第一次月考试题及答案.doc

1、考试场次:2015_01月月考_01月29日_JAVA 试卷名称:2015年01月_JSD_JSD14121. 运行下面的程序: int a = 100; int b = 200; a = a + b; b = a - b; a = a - b; System.out.println(a= + a + , b= + b); 输出的结果是:()。 A. a=100, b=300 B. a=100, b=200 C. a=200, b=100 D. a=300, b=200正确答案:C2. 下面关于数组的声明语句中,有编译错误的是:()。 A. int arr = new int1,2,3; B.

2、 int arr = null;arr = 1,2,3,4,5; C. int arr = new int1,2,3,4,5,6 D. int arr = new int2;正确答案:B3. 分析如下代码,输出结果为()。 public static void main(String args) int i = 0; boolean re = false; re = (+i) + i = 2) ? true : false; System.out.println(i= + i + ,re=+re); A. i=1,re=true B. i=0,re=true C. i=1,re=false D

3、 i=0,re=false正确答案:A4. 请看下列代码:interface Foo int bar();public class Sprite public int fubar(Foo foo) return foo.bar(); public void testFoo() fubar( ); 使类Sprite编译通过,在处应填入的代码是: A. Foo public int bar() return 1; B. new Foo public int bar() return 1; C. new Foo() public int bar()return 1; D. new class Fo

4、o public int bar() return 1; 正确答案:C 5. 程序的执行结果是: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);

5、 else System.out.println(false); A. true true B. truefalse C. false true D. false false正确答案:A6. 下列代码的输出结果是:()。 public class StaticFoo int num; static int x; public static void main(String args) StaticFoo foo1 = new StaticFoo (); foo1.num+; foo1.x+; StaticFoo foo2 = new StaticFoo (); foo2.num+; foo2.

6、x+; StaticFoo foo3 = new StaticFoo (); foo3.num+; foo3.x+; StaticFoo.x+; System.out.print(foo3.num+,); System.out.println(foo3.x); A. 3,3 B. 1,3 C. 3,4 D. 1,4 正确答案:D7. 运行下面的程序:Calendar c = Calendar.getInstance();c.set(Calendar.YEAR, 2012);c.set(Calendar.MONTH, Calendar.SEPTEMBER);c.set(Calendar.DATE

7、 31);SimpleDateFormat sdf = new SimpleDateFormat(yyyy-MM-dd);System.out.println(sdf.format(c.getTime(); 输出的结果是:()。 A. 2012-10-1 B. 2012-10-01 C. 2012-09-30 D. 2012-9-30正确答案:B8. 下列关于JVM说法,错误的是()。 A. JVM通过专门的线程实现内存的回收。 B. 使用java命令时,可以通过参数来设置分配JVM的内存大小。 C. JRE包括JVM及Java核心类库。 D. 目前主流版本JVM通过纯解释的方式运行Java

8、字节码。正确答案:D9. 请看下列代码:public class Plant private String name; public Plant(String name) this.name = name; public String getName() return name; class Tree extends Plant public void growFruit() public void dropLeaves() 下列说法正确的是: A. 在Tree类中添加代码:public Tree() Plant(); ,编译将通过 B. 在Plant类中添加代码:public Plant()

9、 Tree(); ,编译将通过 C. 在Plant类中添加代码:public Plant() this(”fern”); ,编译将通过 D. 在Plant类中添加代码:public Plant() Plant(”fern”); ,编译将通过正确答案:C10. 运行下列程序: String str = *java*java*java*; String str1 = java; int index = 0; while (index = str.indexOf(str1, index) != -1) System.out.print(index+”); index += str1.length()

10、 控制台输出的结果是:()。 A. 1 8 17 B. 2 9 18 C. 5 12 21 D. 6 13 22正确答案:B11. 下列语句创建对象的总个数是:()。 String s=”a”+”b”+”c”+”d”+”e”; A. 1 B. 2 C. 3 D. 4 正确答案:A 12. 下列代码的输出结果是()。 int j=0; for(int i=0;i100;i+) j=j+; System.out.println(j); A. 0 B. 99 C. 100 D. 101 正确答案:A13. 下列代码编译和运行的结果是() public class Foo public static

11、 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.

12、util.List list = new java.util.ArrayList();行,编译错误正确答案:C14. 下面的程序可以输出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;正确答案:B 15. 请看下列代码: public class Person private String name; public Person(String name) th

13、is.name = name; public boolean equals(Person p) return p.name.equals(this.name); 下列说法正确的是: A. Person类的equals方法没有覆盖Object类的equals方法 B. 编译错误,因为私有属性不能在equals方法中被访问 C. 基于Hash的数据结构可以正确工作,但是Person类必须覆盖hashCode方法 D. 当向Set集合中添加Person对象时,equals方法中的return语句能避免重复正确答案:A16. 有变量声明如下: short b = 120; 下列语句中,错误的是()。

14、A. short s = b; B. int i = b; C. byte s1 = b; D. long l = b;正确答案:C 17. Java程序的执行过程中用到一套JDK工具,其中javac.exe是指()。 A. Java语言编译器 B. Java字节码解释器 C. Java文档生成器 D. Java类分解器正确答案:A18. 以下程序的输出结果是: ()。 public class Super public Super() System.out.println(Super ); public class Sub extends Super public Sub() System.

15、out.println(Sub); public static void main(String args) Super fc = new Super(); Sub cc = new Sub(); A. Super Super Sub B. Super Sub C. Sub Super D. Super Sub Sub 正确答案:A19. 下列代码的输出结果是()。 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,

16、2, 2); System.out.println(Arrays.toString(two); A. 1, 3, 7, 4, 6 B. 1, 3, 5, 7, 8 C. 1, 3, 5, 6, 9 D. 1, 3, 6, 8, 9正确答案:D20. 实现Point类的equals方法,具体逻辑为:“成员变量x和y分别相等的Point对象被视为相等”。public class Point private int x; private int y; . public boolean equals(Object obj) 填入代码 插入代码处应填入的代码正确的是: A. if(obj.x = thi

17、s.x | obj.y = this.y) return true; return false; B. if(obj.x = this.x & obj.y = this.y) return true; return false; C. if(!(obj instanceof Point) return false; if(Point)obj).x = (Point)obj).y & this.x = this.y) return true; return false; D. if(!(obj instanceof Point) return false; if(Point)obj).x = t

18、his.x & (Point)obj).y = this.y) return true; return false;正确答案:D21. 下列数组声明语句中,错误的是:()。 A. int arr = new int; B. int arr = new int; C. int arr = ; D. int arr = new int2正确答案:B22. 下面关于interface,叙述错误的是:() A. 一个interface可以继承多个interface B. 接口中的方法可以由private修饰 C. interface中可以定义static final 常量 D. interface中可

19、以无任何方法定义 正确答案:B23. 关于下列代码说法不正确的是:10. interface Foo 11. int bar();12. 13.14. public class Beta 15.16. class A implements Foo 17. public int bar() return 1; 18. 19.20. public int fubar( Foo foo) return foo.bar(); 21.22. public void testFoo() 23.24. class A implements Foo 25. public int bar() return 2;

20、 26. 27.28. System.out.println( fubar( new A();29. 30.31. public static void main( String argv) 32. new Beta().testFoo();33. 34. A. 编译错误 B. 运行代码输出:2 C. 如果删除16,17,18行,运行代码应然输出:2 D. 如果删除24,25,26行,运行代码输出:1正确答案:A 24. 下列代码的输出结果是:class Cup class PoisonCup extends Cup public void takeCup(Cup c) if (c insta

21、nceof PoisonCup) System.out.println(Inconceivable!); else if (c instanceof Cup) System.out.println(Dizzying intellect!); else System.exit(0); public class TestCup public static void main(String args) Cup cup = new PoisonCup(); PoisonCup poison=new PoisonCup(); poison.takeCup(cup); A. Inconceivable!

22、B. Dizzying intellect! C. 代码正常运行,但是无输出 D. 抛出运行时异常正确答案:A 25. 下列关于HashMap的方法描述正确的是: A. containsKey(Object key): 判断集合中是否包含指定的Value B. containsValue (Object value): 判断集合中是否包含指定的Key C. get(Object key):返回与参数Key所对应的Value对象,如果不存在则返回null D. put(K key, V value):将Key-Value对存入Map,如果在集合中已经包含该Key,则操作将替换该Key所对应的Va

23、lue,返回值为该Key当前所对应的Value(如果没有则返回null)正确答案:C 26. 查看如下代码: 1. class HasStatic 2. 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

24、out.println(“x=”+x); 12. 13. 对于此代码,下列描述中,正确的是()。 A. 5行不能通过编译,因为引用了私有静态变量 B. 10行不能通过编译,因为x是私有静态变量 C. 程序通过编译,输出结果为:x=103 D. 程序通过编译,输出结果为:x=102正确答案:D27. 在Java语言中,下列说法正确的是:()。 A. Java访问修饰符按照访问范围由低到高的排列顺序是public,default,protected,private B. private可以用于外部类的声明 C. 一个Java源文件中声明为public的外部类只能有一个 D. protected声

25、明的方法不可以被子类重写正确答案:C28. 下列代码运行的结果是()。 public class Base public static final String FOO = foo; public static void main(String args) Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(Base) s).

26、FOO); class Sub extends Base public static final String FOO = bar; A. foofoofoofoofoo B. foobarfoobarbar C. foobarfoofoofoo D. foobarfoobarfoo正确答案:D29. 在Java中,Integer.MAX_VALUE表示: A. double型最大值 B. int最大值 C. long型最大值 D. char型最大值正确答案:B30. 请看下列代码: public static void main(String args) Calendar c = Calen

27、dar.getInstance(); c.set(Calendar.YEAR, 2013); c.set(Calendar.MONTH, Calendar.FEBRUARY); c.set(Calendar.DATE, 28); 在处填入将Calendar表示的日期转换为Date表示的日期: A. Date d=c.getDate(); B. Date d=c.getCalendar(); C. Date d=c.getNow(); D. Date d=c.getTime();正确答案:D31. 题目代码的功能为:输出每个字符在一个字符串中出现的次数(不区分大小写)。String str =

28、ewrwqFrewqfsadfdsfdsfs;str=str.toLowerCase();int max_length = 0;while (str.length() 0) 插入代码 A. int length = str.length();char first=str.charAt(0);String strNew = str.replaceAll(String.valueOf(first), );if (lengthstrNew.length() max_length = length - strNew.length(); System.out.println(first+:+max_le

29、ngth); B. int length = str.length();char first=str.charAt(0);String strNew = str.replaceAll(String.valueOf(first), );if (lengthstrNew.length() max_length = length - strNew.length(); str = strNew; System.out.println(first+:+max_length); C. int length = str.length();String first = str.substring(0, 1);

30、String strNew = str.replaceAll(first, );if (lengthstrNew.length() max_length = length - strNew.length(); str = strNew; System.out.println(first+:+max_length); D. int length = str.length();String first = str.substring(0, 1);String strNew = str.replaceAll(first, );if (lengthstrNew.length() max_length

31、 length - strNew.length(); System.out.println(first+:+max_length);正确答案:BC32. 请看下列代码: public class Old public static Object get(List list) return list.get(0); 以下选项调用get方法,能编译通过的是: A. Object o = Old.get(new LinkedList(); B. Object o = Old.get(new LinkedList(); C. String s = Old.get(new LinkedList();

32、D. String s = (String)Old.get(new LinkedList();正确答案:AD33. 下列赋值语句中,会有编译错误的是()。 A. int a = 8888888888; B. char b = 1000+300; C. byte c = 100+30; D. int d = a+b+c;正确答案:AC34. 所谓“水仙花”数是一个整数等于各位数字立方的和,例如:153 = 1*1*1+5*5*5+3*3*3,下面的程序用于输出21000内的水仙花数: for (int n = 2; n 0) int t = n1 % 10; s += t * t * t; n1

33、 /= 10; B. int s = 0, n1 = n;while (n1 0) int t = n1 / 10; s+= t * t * t; n1 %= 10; C. int s = 0;for(int n1 = n; n10; n1 /= 10) int t = n1%10; s += t * t * t; D. int s = 0; for(int n1 = n; n10; n1 %= 10) int t = n1 / 10; s += t * t * t; 正确答案:AC 35. 请看下列代码:class One public One foo() return this; clas

34、s Two extends One public One foo() return this; class Three extends Two 下列选项中的代码,放置在处无编译错误的是: A. public void foo() B. public Object foo() return this; C. public Two foo() return this; D. public One foo() return this; 正确答案:CD 36. 在Java语言中,下列说法正确的是:()。 A. StringBuffer和StringBuilder的区别在于:StringBuffer是线

35、程安全的而StringBuilder不是。 B. String是不可变对象,而StringBuffer中封装的字符串数据是可以动态改变的。 C. 判断两个StringBuilder对象的字符序列是否相同,可以调用其equlas方法进行比较。 D. String的重写了equals方法,重写的逻辑是:字符序列相同的String对象equals方法返回true。正确答案:ABD 37. 下列关于HashMap的描述正确的是: A. HashMap的Key和Value是以链表的方式存入对应的bucket B. HashMap的查找方式是获取Key的hashCode值,通过hash算法确定存储的buc

36、ket,调用equals方法依次与bucket中的Key进行比较 C. 放入HashMap集合中的元素按照key的自然顺序排序 D. HashMap中的key是不可以的重复的正确答案:ABD38. 在Java语言中,下列说法正确的是()。 A. 一个接口可以继承多个接口 B. 一个类可以继承多个类 C. 一个类可以实现多个接口 D. 一个类可以有多个子类正确答案:ACD 39. 请看下列代码:public abstract class Shape int x; int y; public abstract void draw(); public void setAnchor(int x, in

37、t y) this.x = x; this.y = y; 下列选项中能正确使用Shape类的是: A. public class Circle implements Shape private int radius; B. public abstract class Circle extends Shape private int radius; C. public class Circle extends Shape private int radius;public void draw(); D. public class Circle extends Shape private int

38、radius;public void draw() /* code here */正确答案:BD40. 在处,填入下列代码编译正确的是: public void foo(int x) A. foreach(int z : x) System.out.println(z); B. for(int z : x) System.out.println(z); C. while( x.hasNext() System.out.println( x.next(); D. for( int i=0; i x.length; i+ ) System.out.println(xi);正确答案:BD41. 阅读

39、理解 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 时,将默认调用父类的无参构造方

宁ICP备18001539号-1