山东浪潮齐鲁软件产业股份有限公司-高级Java软件工程师笔试题

山东浪潮齐鲁软件产业股份有限公司高级Java软件工程师笔试题 选择题1、 关于垃圾收集的那些叙述是对的A、程序开发者必须自己创建一个线程进行内存释放的工作B、 垃圾收集将检查并释放不再使用的内存。C、垃圾收集允许程序开发者明确指定并立即释放该内存D、垃圾收集能够在期望的时间释放被java对象使用的内存答案B  解析Java语言将内存分配和释放的工组交给了
摘要由CSDN通过智能技术生成

山东浪潮齐鲁软件产业股份有限公司

高级Java软件工程师笔试题

 

选择题

1、 关于垃圾收集的那些叙述是对的

A、程序开发者必须自己创建一个线程进行内存释放的工作

B、 垃圾收集将检查并释放不再使用的内存。

C、垃圾收集允许程序开发者明确指定并立即释放该内存

D、垃圾收集能够在期望的时间释放被java对象使用的内存

答案B

  解析Java语言将内存分配和释放的工组交给了自己,程序员不必做这些工作,它提供一个系统级的线程跟踪每个内存的分配,在JVM的空闲处理中,垃圾收集线程将检查和释放不再使用的内存(即可以被释放的内存)。垃圾收集的过程在java程序的生存期中是自动的,不需要分配和释放内存,也避免了内存泄漏。可以调用Systemgc()方法建议(suggestJVM执行垃圾收集以使得可被释放的内存能立即被使用,当此方法返回的时候,JVM已经做了最大的努力从被丢弃的对象上回收内存空间。程序员不能指定收集哪些内存,一般而言也不用关心这个问题,除非是程序的内存消耗很大,特别是有很多临时对象时可以建议进行垃圾收集以提高可用内存。需要指出的是调用Systemgc()方法不能保证JVM立即进行垃圾收集,而只能是建议,因为垃圾收集线程的优先级很低(通常是最低的)。

 

2、 在软件生命周期中,下列哪个说法是不准确的?

A、软件生命周期分为计划、开发和运行三个阶段

B、 在计划阶段要进行问题研究和需求分析

C、在开发后期要进行编写代码和软件测试

D、在运行阶段主要是进行软件维护

 

3、 Give the following java class:

Public classExample{

static intx[]=new int[15];

public staticvoid main(String args[])

{

        System.out.println(x[5]);

}

}

Which statementis corrected?

A、When compile,some error willoccur.    A  Static int x[]有问题

B、When run,some error will occur.

C、Output is zero

D、Output is null

4、 设有变量说明语句int a=1,b=0;

则执行以下程序段的输出结果为()

Switch(a)

{

case 1:

 switch(b)

{

      case 0:printf(“**0**”);break;

      case 1:printf(“**1**”);break;

}

Case 2:printf(“**2**”);break;

}

Printf(“\n”);

A、**0**

B**0****2**

C、**0****1****2**

D、有语法错误

   *0** **2**;

先输出0,由于最外面case1 没Break,所以继续case2,输出2;

5、 What is written to thestandard output given the following statement : System.out.println(4 | 7);

Select the rightanswer:

       A、4

       B、5

       C、6

       D7

|”是按位或运算符,先将47转为二进制数。转换后就是计算“100|111”,所以得到结果是“111”,转为十进制整形数是7。此题提醒考生注意,要熟悉各种运算符号的含义

6、 Which method you define as thestarting point of new thread in a class from which new the thread can beexcution?

A、    public void start()

B、   public void run()

C、    public void runnable()

D、    public static void main(String args[])

线程的执行是从方法“run( )”开始的,该方法是由系统调用的。程序员手工调用方法start(),使线程变为可运行状态。

7.Which are not Java keywords?

A.TRUE

B.const

C.super

D.void

 

8.What will happen when you attempt tocompile and run the following code?

(Assume that the code is compiled and runwith assertions enabled)

public class AssertTest{

public void methodA(int i){

assert i>=0:methodB();

System.out.println(i);

}

public void methodB(){

System.out.println(“The value must not benegative”);

}

public static void main(String[] args){

AssertTest test = new AssertTest();

Test.methodA(-10);

}

}

A.    will print -10;

B.     it will result inAssertionError showing the message “the value must not be negative”.

C.     The code will not compile

D.    None of these

9.Which of the following statements aretrue?

A.The automatic garbage collection of theJVM prevents programs from ever running out of memory java虚拟机的自动垃圾回收机制可以避免内存不足的情况发生。

B.A program can suggest that garbage collection be performed and forceit.

C.Garbage collection is platformindependent.

D.An object become eligible for garbage collection when all referencesdenoting it are set to null.

 

10、What will happen when you attempt to compile and run the followingcode ?

Class Base{

       inti=99;

public void amethod()

{

       System.out.println(“Base.amethod()”);

}

Base()

{

       Amethod();

}

}

Public class Derived extends Base

{

       Inti=-1;

       Publicstatic void main(String  argv[])

{

              Base b =new Derived();

              System.out.println(b.i);

b.amethod();

}

Public void amethod()

{

       System.out.println(“Derived.amethod()”);

}

}

Choices:

A.    Derived.amethod()-1Derived.amethod()

B.     Derived.amethod() 99 Derived.amethod()

C.     Compile time error

D.    Derived.amethod()

 

11.when is the float object created in line3,eligible(合适的, 适当的) for garbage collection ?

1.public classX{

2 public objectm(){

3. object o=newfloat(3.14F);

4. object []oa =new object[1];

5. oa[0]=o;

6. o=null;

7. oa[0] = null;

8. return 0;

9. }

10.}

  1. Just after line 5
  2. Just after line 6
  3. Juest after line 7
  4. Just after line 8(that is ,as the method returns)

 

12:What will happen when you attempt tocompile and run the following code?

Public class static

{

Static

{

Int x=5;

}

Static int x,y;

Public static void main(string args[])

{

       x--;

       myMethod();

       System.out.println(x+y +++x);

}

Public static void myMethod()

{

       Y=x++ + ++x;

}

}

Choices:

A.    PRINTS:2

B.     PRINTS:3

C.     PRINTS:7

D.    PRINTS:8

 

13. which code fragments(碎片; 片断)would correctly identify the number of arguments passed via command line to ajava application ,exclude the name of class that is being invoke.

       A.int count=args.length;

   

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值