企业面试题(附答案)(3)

2019-01-07 16:52

9) } 10) } A. B. C. D.

4 6 7 8

解答:C

k没有初始化就使用了

24.对记录序列{314,298,508,123,486,145}按从小到大的顺序进行插入排序,经过两趟

排序后的结果为:(选择1项) A B C

{314,298,508,123,145,486} {298,314,508,123,486,145} {298,123,314,508,486,145}

D {123、298,314,508,486,145} 解答:B 插入排序算法:

public static void injectionSort(int[] number) {

// 第一个元素作为一部分,对后面的部分进行循环 for (int j = 1; j < number.length; j++) { } }

int tmp = number[j]; int i = j - 1;

while (tmp < number[i]) { }

number[i + 1] = tmp;

number[i + 1] = number[i]; i--; if (i == -1)

break;

25.栈是一种。(选择1项) A 存取受限的线性结构 B C D

存取不受限的线性结构 存取受限的非线性结构 存取不受限的非线性结构

解答:A

栈(stack)在计算机科学中是限定仅在表尾进行插入或删除操作的线性表。 26.下列哪些语句关于内存回收的说明是正确的。(选择1项) A程序员必须创建一个线程来释放内存 B内存回收程序负责释放无用内存 C内存回收程序允许程序员直接释放内存 D内存回收程序可以在指定的时间释放内存对象 解答:B

垃圾收集器在一个Java程序中的执行是自动的,不能强制执行,即使程序员能明确地判断出

有一块内存已经无用了,是应该回收的,程序员也不能强制垃圾收集器回收该内存块。程序员唯一能做的就是通过调用System. gc 方法来\建议\执行垃圾收集器,但其是否可以执行,什么时候执行却都是不可知的。

27.Which method must be defined by a class implementing the java.lang.Runnable

interface? A. void run() B. public void run() C. public void start() D. void run(int priority) E. public void run(int priority) F. public void start(int priority) 解答:B

实现Runnable接口,接口中有一个抽象方法run,实现类中实现该方法。 28 Given:

public static void main(String[] args) { Object obj = new Object() {

public int hashCode() { return 42; } };

System.out.println(obj.hashCode()); }

What is the result? A. 42

B. An exception is thrown at runtime.

C. Compilation fails because of an error on line 12. D. Compilation fails because of an error on line 16. E. Compilation fails because of an error on line 17. 解答:A

匿名内部类覆盖hashCode方法。

29 Which two are reserved words in the Java programming language? (Choose two) A. run B. import C. default D. implements 解答:BD

import导入包的保留字,implements实现接口的保留字。

30. Which two statements are true regarding the return values of property written

hashCodeand equals methods from two instances of the same class? (Choose two) A. If the hashCode values are different, the objects might be equal. B. If the hashCode values are the same, the object must be equal. C. If the hashCode values are the same, the objects might be equal. D. If the hashCode values are different, the objects must be unequal. 解答:CD

先通过 hashcode来判断某个对象是否存放某个桶里,但这个桶里可能有很多对象,那么我们

就需要再通过 equals 来在这个桶里找到我们要的对象。

31. What is the numerical range of a char? A. 0 ... 32767 B. 0 ... 65535 C. –256 ... 255 D. –32768 ... 32767

E. Range is platform dependent. 解答:B

在Java中,char是一个无符号16位类型,取值范围为0到65535。 32. Given:

public class Test {

private static float[] f = new float[2]; public static void main(String args[]) { System.out.println(“f[0] = “ + f[0]); } }

What is the result? A. f[0] = 0 B. f[0] = 0.0 C. Compilation fails.

D. An exception is thrown at runtime. 解答:B 33. Given:

public class Test {

public static void main(String[] args) { String str = NULL; System.out.println(str); } }

What is the result? A. NULL

B. Compilation fails.

C. The code runs with no output. D. An exception is thrown at runtime. 解答:B null应该小写 34、Exhibit:

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.}

What is the result? A. B. C.

An error at line 11 causes compilation to fail. Errors at lines 7 and 8 cause compilation to fail.

The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”) D.

The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)


企业面试题(附答案)(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017年电大学前游戏理论与指导形成性考核册答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: