达内JSD1412第一次月考试题及答案.doc
《达内JSD1412第一次月考试题及答案.doc》由会员分享,可在线阅读,更多相关《达内JSD1412第一次月考试题及答案.doc(16页珍藏版)》请在三一文库上搜索。
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;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JSD1412 第一次 月考 试题 答案
