鲁东大学
  1. 执行下列代码后,哪个结论是正确的 String[] s=new String[10];

  2. A:s[10] 为 ""; B:s[0] 为 未定义 C:s.length 为10 D:s[9] 为 null;
    答案:s[9] 为 null;###s.length 为10
  3. 读代码:1. public interface Foo{2.int k = 4;3. }Which three are equivalent to line 2? (Choose Three)

  4. A:Volatile int k = 4; B:static int k = 4; C:Transient int k = 4; D:final int k = 4; E:Abstract int k = 4; F:Private int k = 4; G:Public int k = 4;
    答案:Private int k = 4;###Abstract int k = 4;###Public int k = 4;
  5. 链表具有的特点是:

  6. A:可随机访问任一元素 B:插入删除不需要移动元素 C:不必事先估计存储空间 D:所需空间与线性表长度成正比
    答案:插入删除不需要移动元素###不必事先估计存储空间###所需空间与线性表长度成正比
  7. 指出下列哪个方法与方法public void add(int a){}为合理的重载方法。

  8. A:public void add(double a) B:public int add(int a) C:public void add(float a) D:public void add(int a,int b)
    答案:public void add(int a,int b)###public void add(double a)###public void add(float a)
  9. 读代码:public class OuterClass {private double d1 = 1.0;//insert code here}在第3行插入内部类声明正确的是:

  10. A:static class InnerOne { public double methoda() {return d1;} } B:protected class InnerOne { static double methoda() {return d1;} } C:public abstract class InnerOne { public abstract double methoda(); } D:private class InnerOne { public double methoda() {return d1;} } E:static class InnerOne { static double methoda() {return d1;} }
    答案:public abstract class InnerOne { public abstract double methoda(); }###private class InnerOne { public double methoda() {return d1;} }
  11. short c = 8;byte d = 16; System.out.println("c | d =" + (c | d));

  12. A:1 B:12 C:24 D:-8
    答案:24
  13. 下面的代码实现了设计模式中的什么模式public class A { private A instance; private A() { } public static A getInstance() { if ( A == null ) instance = new A(); return instance; } }

  14. A:Singleton B:Abstract Factory C:Builder D:Factory
    答案:Singleton
  15. 下列常见的系统定义的异常中,哪个是输入、输出异常?

  16. A:FileNotFoundExceptio B:IOException C:ClassNotFoundException D:UnknownHostException
    答案:IOException
  17. 关于构造方法constructor,下列说法正确的是()

  18. A:constructor必须与class同名,且区分返回值的类型。 B:constructor在一个对象被new时执行 C:一个class只能定义一个constructor D:class中的constructor不可省略
    答案:constructor在一个对象被new时执行
  19. 下列哪一项的标准输入设备是键盘?

  20. A:System.out B:System.gc() C:System.in D:System.err
  21. 阅读下列的程序 public class Test3 {public static void main(String[] args) { _________________________ _________________________ } }class Outer {static class Inner {public void method () {System.out.println(\ } } }下列选项中,可以正确输出method()方法的是

  22. A:Outer o = new Outer(); o.method(); B:Outer.Inner oi = new Outer.Inner(); oi.method() C:Inner I = new Inner(); i.method();
  23. 关于数组,以下说法错误的是()

  24. A:数组是对象,它作为参数传递时的特点和对象是一致的。 B:数组内容的复制可以通过循环实现,也可以通过System.arraycopy实现。 C:当二维数组声明时,int[][] numbers=new int[10][];数组的长度就确定了。 D:使用符号=对数组对象赋值时是将对象引用指向同一个数组,而不是将数组内容进行复制。
  25. 给出程序的运行结果()class Person { String name; int age; Person(){ System.out.println("Person()"); } void Person(){ System.out.println("method()"); } public void tell() { System.out.println("姓名:" + name + ",年龄:" + age); } }public class ClassTest02 { public static void main(String[] args) { Person person = new Person(); person.name = "张三"; person.age = 30; person.tell(); }}

  26. A:Person()
    method()
    姓名:张三,年龄:30
    B:method()
    姓名:张三,年龄:30
    C:姓名:张三,年龄:30 D:Person()
    姓名:张三,年龄:30
  27. Java中提供了名为()的包装类来包装原始int类型?

  28. A:Integer B:Character C:Long D:Double
  29. 读代码:public class Test {public static void main (String args[]) {class Foo {public int i = 3;}Object o = (Object) new Foo();Foo foo = (Foo)o;System.out.println(foo.i);}}结果是:

  30. A:编译失败 B:编译成功,程序输出 “3” C:编译成功但会在第7行抛出ClassCastException.Compilation D:编译成功但会在第6行抛出ClassCastException
  31. 下面哪个是正确的?( )

  32. A:String temp [] = {“a” “b” “c”} B:String temp = {“a”, “b”, “c”} C:String temp [] = new String {“a” “b” “c”}; D:String temp [] = {“a”, “b”, “c”}
  33. public class ChangeStrDemo { public static void changeStr(String str){ str="welcome"; } public static void main(String[] args) { String str="home"; changeStr(str); System.out.println(str); } }给出程序的运行结果( )

  34. A:welcome B:无输出 C:home
  35. 以下抽象类的定义中,错误的是?

  36. A:abstract class Demo4{ public static final String CZBK = \高等教育 \ B:abstract class Demo1{} C:abstract class Demo3{ public String fun(){ return \ D:abstract class Demo2{ public abstract String fun(String a); }
  37. 关于实例方法和类方法,以下描述正确的是:( )

  38. A:类方法既可以访问类变量,也可以访问实例变量 B:类方法只能通过类名来调用 C:实例方法只能访问实例变量 D:实例方法只能通过对象来调用
  39. 下列选项中,哪个是程序的运行结果class Test {public static void main(String[] args) {int a = 3; int b = 6;System.out.print(a==b); System.out.print(a=b);} }

  40. A:true false false true B:false false true false C:false false true true D:false true true false
  41. 下列哪个赋值语句是不正确的?

  42. A:double d = 5.3E12; B:double f=11.1E10f; C:float f = 11.1; D:float d = 3.14f ;
  43. 关于java.lang.String类,以下描述正确的一项是( )

  44. A:String类不是final类故不可以继承; B:String类是final类故可以继承; C:String类不是final类故可以继承; D:String类是final类故不可以继承;
  45. 下列哪个不是Java语言的关键字?

  46. A:return B:NULL C:static D:protected
  47. 在Java中,下列()类不能派生出子类( )

  48. A:class MyClass{} B:abstract class MyClass{} C:final class MyClass{} D:public class MyClass{}
  49. Outer类中定义了一个成员内部类Inner,需要在main()方法中创建Inner类实例对象,以下四种方式哪一种是正确的?

  50. A:Outer.Inner in = new Outer().new Inner(); B:Inner in = new Inner() C:Outer.Inner in = new Outer.Inner(); D:Inner in = new Outer.Inner();
  51. 从下面四段代码中选择出正确的代码段()

  52. A:public class Something {
    public int addOne(final int x) {
    return ++x; }
    }
    B:public class Something {
    public static void main(String[] args) {
    Other o = new Other();
    new Something().addOne(o);
    }
    public void addOne(final Other o) {
    o.i++;
    }
    }
    class Other {
    public int i;
    }
    C:abstract class Name {
    private String name;
    public abstract boolean isStupidName(String name) {}
    }
    D:public class Something {
    void doSomething () {
    private String s = ̶”;
    int l = s.length();
    }
    }
  53. class First{public First(){aMethod(); } public void aMethod(){System.out.println(“in First class”);} } public class Second extends First{ public void aMethod(){System.out.println(“in Second class”);}public static void main(String[ ] args){new Second( ); } }

  54. A:in First class B:in Second class C:无输出 D:in First class
    in Second class
  55. 下面关于path和classpath的说法中,错误的是

  56. A:classpath用来指定我们自己所写的或要用到的类文件(.jar文件) 所在的目录 B:在dos命令行中,classpath和path环境变量的查看与配置的方式不相同 C:只要设置了classpath 这个环境变量系统就不会再在当前目录下查询某个类 D:path用来指定 java 虚拟机(JVM) 所在的目录
  57. 下面的程序中,哪行会报错?public class StaticTest { int age; String name; static int totalFee = 500; public void showName() { System.out.print(this.name); } public static void showTotalFee() {line 1: System.out.print(totalFee);line 2: showName(); } public static void main(String[] args) {line3: StaticTest.showTotalFee(); }}

  58. A:line 2 B:line 1 C:line 3
  59. 下列程序的执行,说法错误的是(C)publicclassMultiCatch{publicstaticvoidmain(Stringargs[]){try{inta=args.length;intb=42/a;intc[]={1};c[42]=99;System.out.println(“b=”+b);}catch(ArithmeticExceptione){System.out.println(“除0异常:”+e);}catch(ArrayIndexOutOfBoundsExceptione){System.out.println(“数组超越边界异常:”+e);}}}A、程序将输出第15行的异常信息下列程序的执行,说法错误的是:public class MultiCatch{public static void main(String args[]){try{ int a=args.length; int b=42/a; int c[]={1}; c[42] = 99; System.out.println(“b=”+b);} catch(ArithmeticException e) { System.out.println(“除0异常:”+e);} catch(ArrayIndexOutOfBoundsException e) { System.out.println(“数组超越边界异常:”+e); } }}

  60. A:程序第10行出错 B:程序将输出第15和18行的异常信息 C:程序输出b=12 D:程序将输出第15行的异常信息
  61. nt A = 55;char B = 'E';System.out.println(A + B);

  62. A:125 B:124 C:65 D:55
  63. 接口是Java面向对象的实现机制之一,以下说法正确的是:( )

  64. A:Java支持多重继承,但一个类只可以实现一个接口。 B:Java只支持单重继承,一个类可以实现多个接口; C:Java只支持单重继承,一个类只可以实现一个接口; D:Java支持多重继承,一个类可以实现多个接口;
  65. 数组越界访问会发生什么错误?

  66. A:java.io.IOException B:java.lang.IndexOutOfBoundsException C:java.lang.Exception D:java.lang.ArrayIndexOutOfBoundsException
  67. 读代码:public class SwitchTest {public static void main (String []args) {System.out.println (“value =” +switchIt(4));}public static int switchIt(int x) {int j = 1;switch (x) {case 1: j++;case 2: j++;case 3: j++;case 4: j++;case 5: j++;default:j++;}return j + x;}}第3行的输出是:

  68. A:Value =6 B:Value =4 C:Value =3 D:Value =5 E:Value =7 F:Value =8
  69. 读代码:public class ExceptionTest {class TestException extends Exception {}public void runTest () throws TestException {}public void test () /* Point X*/ {runTest ();}}第4行//point X 位置, 加哪行代码能让代码可编译

  70. A:throws Exception B:No code is necessary C:Catch (TestException e) D:Throws RuntimeException E:Catch (Exception e)
  71. 当编译并运行下面程序时会出现什么结果( )public class MyAr{public static void main(String argv[]){int[] i = new int[5];System.out.println(i[5]);}}

  72. A:输出0 B:运行错误:ArrayIndexOutOfBoundsException C:输出null D:编译错误
  73. 读代码:1.public class X implements Runnable {2. private int x;3. private int y;4. public static void main(String [] args) {5. X that = new X();6. (new Thread(that)).start();7. (new Thread(that)).start();8. }9. public synchronized void run( ){10. for (;;) {11. x++;12. y++;13. System.out.println(“x = “ + x + “, y = “ + y);14. }15. }16.}程序执行后的结果是:

  74. A:第7、8行编译失败 B:程序打印的xy的值总是相同(比如, “x=1, y=1”.另外,每个值出现两次 (比如, “x=1, y=1” 跟在“x=1, y=1”之后) C:程序打印出xy的成对值,但它们不一定总是相同 (比如, “x=2, y=1”) D:程序打印的xy的值总是相同(比如, “x=1, y=1”.另外,每个值出现两次 (比如, “x=1, y=1” 跟在“x=2, y=2”之后) E:11行发生编译错误
  75. java.lang包的()方法比较两个对象是否相等,相等返回true。

  76. A:其余所有选项都不正确 B:equals() C:compare() D:toString()
  77. 题目:1. public class test (2. public static void main (String args[]) {3. int i = 0xFFFFFFF1;4. int j = ~i;5.6. }7. )程序运行到第5行时,j的值为多少?( )

  78. A:在第三行的错误导致编译失败 B:1 C:14 D:–15 E:0
  79. 以下代码运行输出是()class Man { private String name = "Jack"; int age = 30;}public class ManTest { public String tel; public static void main(String[] args) { Man m = new Man(); System.out.println(m.name); }}

  80. A:运行出错 B:输出:Jack C:编译出错 D:没有输出
  81. 以下关于数组的操作正确的是

  82. A:int[ ][ ] array = new int[ ][7]; B:int[ ] array = new int[ ]; C:int[ ] array = {50,60,34,52}; D:int[ ] array = new int[2]{6,87};
  83. 读代码:1.package foo;2.import java.util.Vector;3.private class MyVector extends Vector {4.int i = 1;5.public MyVector() {6.i = 2;7. }8.}9.public class MyNewVector extends MyVector {10.public MyNewVector () {11. i = 4;12.}13.public static void main (String args []) {14.MyVector v = new MyNewVector();15. }16.}结果是:

  84. A:编译成功 B:在第6行编译错误 C:在第14行编译错误 D:在第9行编译错误 E:在第3行编译错误
  85. 读代码:public class Test {public static void main (String [] args) {String foo = “blue”;String bar = foo;foo = “green”;System.out.println(bar);}}结果是:

  86. A:程序打印 “null” B:代码无法编译 C:打印“green” D:会抛出异常 E:打印“blue”
  87. 下面的集合中,不可以存储重复元素的是

  88. A:List B:Collection C:Set D:Map
  89. 哪个关键字可以抛出异常?

  90. A:transient B:finally C:static D:throw
  91. final是修饰符(关键字)可以修饰类、方法、变量

  92. A:错 B:对
  93. Map继承List

  94. A:对 B:错
  95. Java可以在任何机器上运行吗?

  96. A:错 B:对
  97. 高级语言编写的程序不能直接被计算机识别,必须经过转换才能被执行。

  98. A:错 B:对
  99. 类是Java语言的一种基本数据类型。

  100. A:对 B:错

温馨提示支付 ¥5.00 元后可查看付费内容,请先翻页预览!
点赞(3) dxwkbang
返回
顶部