1、 北京东华合创数码科技股份公司 地址:北京市海淀区知春路 128 号泛亚大厦 3 层Tel:010-62524608 Fax:010-62524618 邮编:100086 1北京东华合创数码科技股份有限公司笔试试卷(Java 语言部分)姓名: 联系方式: 1. which wont cause a compiler warning or error?(多选)a) float f = 1.3;b) char c = a;c) byte b = 257;d) boolean b = null;e) int i = 10;2. 请选择下面这段代码的输出结果?int i = 0;switch (i)
2、case 0:System.out.println(“zero“);case 1:System.out.println(“one“);case 2:System.out.println(“two“);break;case 3:System.out.println(“three“);1) zero2) zero,one3) zero,one,two4) zero,one,two,three3. public class Test private static int j=0; public static boolean methodB(int k) j+=k; return true; 北京东华
3、合创数码科技股份公司 地址:北京市海淀区知春路 128 号泛亚大厦 3 层Tel:010-62524608 Fax:010-62524618 邮编:100086 2public static void methodA(int i) boolean b; b=i10 b=i10 public static void main(String args) methodA(0); 17) what is the value of j at line 17? 1)0 2)1 3)24)34. If we execute the code below with “java Test Red Green B
4、lue”, what is the result? public class Test public static void main(String args) String foo=args1; String bar=args2; String baz=args3; what is the value of baz? A. baz has value of “ B. baz has value of null C. baz has value of “Red“ D. baz has value of “Blue“ E. baz has value of “Green“ F. the code
5、 does not compile G. the program throw an exception5. 请选择下面这段代码的输出结果?1)public class Test 2)public static void main(String args) 3) class Foo 4) public int i=3; 5) 北京东华合创数码科技股份公司 地址:北京市海淀区知春路 128 号泛亚大厦 3 层Tel:010-62524608 Fax:010-62524618 邮编:100086 36)Object o=(Object)new Foo(); 7) Foo foo=(Foo)o; 8)
6、System.out.println(foo.i); 9) 10) A.compile error at line 6 B.compile error at line 7 C.compile error at line 8 D.print out 36. int index=1; String test=new String3; String foo=testindex; what is the result of foo? A. “ B.null C.throw a Exception D.not compile7. 下面的五个选择中哪两个描述是正确的?(多选)A. static inner
7、 class requires a static initializer B. A static inner class requires an instance of the enclosing class C. A static inner class has no reference to an instance of the enclosing class D. A static inner class has accesss to the non-static member of the other class E. static members of a static inner
8、class can be referenced using the class name of the static inner class8. 请选择下面这段代码的输出结果? class A public int getNumber(int a) return a+1; class B extends A public int getNumber(int a, char c) return a+2; public static void main(String args) B b=new B(); System.out.println(b.getNumber(0); 北京东华合创数码科技股份
9、公司 地址:北京市海淀区知春路 128 号泛亚大厦 3 层Tel:010-62524608 Fax:010-62524618 邮编:100086 4 A. compilation succeeds and 1 is printed B. compilation succeeds and 2 is printed C. An error at line 8 cause compilation to fail D. An error at line 14 cause compilation to fail9. class ExceptionTest public static void main(
10、String args) try methodA(); catch(IOException e) System.out.println(“caught IOException“); catch(Exception e) System.out.println(“caught Exception“); If methodA() throws a IOException, what is the result?If we change the sequence of catch,whats the result?10. 请写出下面这段代码的输出结果?public class Test public
11、static void main(String args) StringBuffer a=new StringBuffer(“A“); StringBuffer b=new StringBuffer(“B“); operate(a,b); System.out.pintln(a+“,“+b); public static void operate(StringBuffer x, StringBuffer y) x.append(y); y=x; 北京东华合创数码科技股份公司 地址:北京市海淀区知春路 128 号泛亚大厦 3 层Tel:010-62524608 Fax:010-62524618
12、邮编:100086 511. 请写出下面这段代码的输出结果?class ShapeShape(int i)System.out.println(“This is Shape“ + i);public class Circle extends Shapestatic Shape s1 = new Shape(1);Shape s2 = new Shape(3);Circle(int i)super(i);System.out.println(“This is Circle“ + i);public static void main(String args)Circle c1 = new Circle(2);12. 数组有没有 length()这个方法? String 有没有 length()这个方法?