Java开发工程师 笔试题.docx

上传人:b****6 文档编号:6997577 上传时间:2023-01-15 格式:DOCX 页数:21 大小:20.86KB
下载 相关 举报
Java开发工程师 笔试题.docx_第1页
第1页 / 共21页
Java开发工程师 笔试题.docx_第2页
第2页 / 共21页
Java开发工程师 笔试题.docx_第3页
第3页 / 共21页
Java开发工程师 笔试题.docx_第4页
第4页 / 共21页
Java开发工程师 笔试题.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

Java开发工程师 笔试题.docx

《Java开发工程师 笔试题.docx》由会员分享,可在线阅读,更多相关《Java开发工程师 笔试题.docx(21页珍藏版)》请在冰豆网上搜索。

Java开发工程师 笔试题.docx

Java开发工程师笔试题

选择题

1:

Whichofthefollowingstatementsarenotlegal?

A.longl=4990;

B.inti=4L;

C.doubled=34.4;

D.doublet=0.9F.

2:

What will happen when you attempt to compile 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:

  

Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?

publicclassStatic

{

static

{

intx=5;

}

staticintx,y;

publicstaticvoidmain(Stringargs[])

{

x--;

myMethod();

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

}

publicstaticvoidmyMethod()

{

y=x+++++x;

}

}

Choices:

A.prints:

2

B.prints:

3

C.prints:

7

D.prints:

8

3:

Give the code fragment:

  

if(x>4){  

System.out.println(“Test 1”);}  

else if (x>9){  

System.out.println(“Test 2”);}  

else {  

System.out.println(“Test 3”);}  

Which range of value x would produce of output “Test 2”?

   

Givethecodefragment:

if(x>4){

System.out.println(“Test1”);}

elseif(x>9){

System.out.println(“Test2”);}

else{

System.out.println(“Test3”);}

Whichrangeofvaluexwouldproduceofoutput“Test2”?

A.x<4

B.x>4

C.x>9

D.None

4:

Math.round(-11.5)等於多少?

A.-11

B.-12

C.-11.5

D.none

5:

publicclassParent{

  intchange(){…}

}

classChildextendsParent{

}

WhichmethodscanbeaddedintoclassChild?

A.publicintchange(){}

B.abstractintchang(){}

C.privateintchange(){}

D.none

6:

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

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

B.在计划阶段要进行问题焉醛和需求分析

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

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

7:

Give the following java class:

  

public class Example{  

public static void main(String args[]){  

static int x[] = new int[15];  

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

}  

}  

Which statement is corrected?

  

Givethefollowingjavaclass:

publicclassExample{

publicstaticvoidmain(Stringargs[]){

staticintx[]=newint[15];

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

}

}

Whichstatementiscorrected?

A.Whencompile,someerrorwilloccur.

B.Whenrun,someerrorwilloccur.

C.Outputiszero.

D.Outputisnull.

8:

假定a和b为int型变量,则执行下述语句组后,b的值为

a=1;

b=10;

do

{

b-=a;

a++;

}while(b--<0);

A.9

B.-2

C.-1

D.8

9:

软件生命周期的瀑布模型把软件项目分为3个阶段、8个子阶段,以下哪一个是正常的开发顺序?

A.计划阶段、开发阶段、运行阶段

B.设计阶段、开发阶段、编码阶段

C.设计阶段、编码阶段、维护阶段

D.计划阶段、编码阶段、测试阶段

10:

What will happen when you attempt to compile and run the following code?

   

  

class Base   

  

{  

  

int i = 99;   

  

public void amethod()  

  

{  

  

       System.out.println("Base.amethod()");  

  

     }  

  

     Base()  

  

{  

  

     amethod();  

  

     }  

  

}   

  

public class Derived extends Base  

  

{  

  

int i = -1;  

  

         

  

public static void main(String argv[])  

  

{  

  

     Base b = new Derived();  

  

       System.out.println(b.i);  

  

       b.amethod();  

  

     }   

  

     public void amethod()  

  

{  

  

       System.out.println("Derived.amethod()");  

  

     }   

  

}   

  

Choices:

  

Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?

classBase

{

inti=99;

publicvoidamethod()

{

System.out.println("Base.amethod()");

}

Base()

{

amethod();

}

}

publicclassDerivedextendsBase

{

inti=-1;

publicstaticvoidmain(Stringargv[])

{

Baseb=newDerived();

System.out.println(b.i);

b.amethod();

}

publicvoidamethod()

{

System.out.println("Derived.amethod()");

}

}

Choices:

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

B.Derived.amethod()99

C.Compiletimeerror

D.Derived.amethod()

11:

Give this class outline:

  

class Example{  

private int x;  

//rest of class body…  

}  

Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?

  

Givethisclassoutline:

classExample{

privateintx;

//restofclassbody…

}

AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?

A.Changeprivateintxtopublicintx

B.changeprivateintxtostaticintx

C.Changeprivateintxtoprotectedintx

D.changeprivateintxtofinalintx

12:

Which is the most appropriate code snippet that can be inserted at line 18 in the following code?

  

  

(Assume that the code is compiled and run with assertions enabled)  

  

1.  import java.util.*;  

  

2.   

  

3.  public class AssertTest  

  

4.  {  

  

5.      private HashMap cctld;  

  

6.       

  

7.      public AssertTest()  

  

8.      {  

  

9.          cctld = new HashMap();  

  

10.         cctld.put("in", "India");  

  

11.         cctld.put("uk", "United Kingdom");  

  

12.         cctld.put("au", "Australia");  

  

13.         // more code...   

  

14.     }  

  

15.     // other methods ....    

  

16.     public String getCountry(String countryCode)  

  

17.     {  

  

18.         // What should be inserted here?

  

  

19.         String country = (String)cctld.get(countryCode);  

  

20.         return country;  

  

21.     }  

  

22. }  

Whichisthemostappropriatecodesnippetthatcanbeinsertedatline18inthefollowingcode?

(Assumethatthecodeiscompiledandrunwithassertionsenabled)

1.importjava.util.*;

2.

3.publicclassAssertTest

4.{

5.privateHashMapcctld;

6.

7.publicAssertTest()

8.{

9.cctld=newHashMap();

10.cctld.put("in","India");

11.cctld.put("uk","UnitedKingdom");

12.cctld.put("au","Australia");

13.//morecode...

14.}

15.//othermethods....

16.publicStringgetCountry(StringcountryCode)

17.{

18.//Whatshouldbeinsertedhere?

19.Stringcountry=(String)cctld.get(countryCode);

20.returncountry;

21.}

22.}

A.assertcountryCode!

=null;

B.assertcountryCode!

=null:

"Countrycodecannotbenull";

C.assertcctld!

=null:

"Nocountrycodedataisavailable";

D.assertcctld:

"Nocountrycodedataisavailable";

13:

给出下面的代码片断。

下面的哪些陈述为错误的?

  

1) public void create() {  

2)    Vector myVect;  

3)    myVect = new Vector();  

4) }  

给出下面的代码片断。

下面的哪些陈述为错误的?

1)publicvoidcreate(){

2)VectormyVect;

3)myVect=newVector();

4)}

A.第二行的声明不会为变量myVect分配内存空间。

B.第二行语句创建一个Vector类对象。

C.第三行语句创建一个Vector类对象。

D.第三行语句为一个Vector类对象分配内存空间

14:

Give the following java source fragement:

  

//point x  

public class Interesting{  

//do something  

}  

Which statement is correctly Java syntax at point x?

   

Givethefollowingjavasourcefragement:

//pointx

publicclassInteresting{

//dosomething

}

WhichstatementiscorrectlyJavasyntaxatpointx?

A.publicclassMyClass{//dootherthing…}

B.staticintPI=3.14

C.classMyClass{//dosomething…}

D.none

15:

Whichstatementaboutlisteneristrue?

A.Mostcomponentallowmultiplelistenerstobeadded.

B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.

C.Componentdon?

tallowmultiplelistenerstobeadd.

D.none

16:

public class X{  

  

   public Object m(){  

  

      Object o = new Float(3.14F);//line 3  

  

      Object [] oa = new Object[1];//line 4  

  

      oa[0] = o;//line 5  

  

      o=null;//line 6  

  

      return oa[0];//line 7  

  

     }  

  

}  

When is the Float object, created in line 3,eligible for garbage collection?

  

publicclassX{

publicObjectm(){

Objecto=newFloat(3.14F);//line3

Object[]oa=newObject[1];//line4

oa[0]=o;//line5

o=null;//line6

returnoa[0];//line7

}

}

WhenistheFloatobject,createdinline3,eligibleforgarbagecollection?

A.justafterline5.

B.justafterline6

C.justafterline7(thatis,asthemethodreturns)

D.neverinthismethod

17:

What will be printed when you execute the following code?

   

  

class X   

{  

  Y b = new Y();  

  X()   

 {   

   System.out.print("X");   

  }  

}   

  

class Y   

{  

    Y()   

   {   

     System.out.print("Y");   

   }  

}   

  

public class Z extends X   

{  

   Y y = new Y();   

  Z()   

 {   

    System.out.print("Z");   

  }   

   public static void main(String[] args)   

  {  

               new Z();  

  }  

}   

  

Choices:

  

Whatwillbeprintedwhenyouexecutethefollowingcode?

classX

{

Yb=newY();

X()

{

System.out.print("X");

}

}

classY

{

Y()

{

System.out.print("Y");

}

}

publicclassZextendsX

{

Yy=newY();

Z()

{

System.out.print("Z");

}

publicstaticvoidmain(String[]args)

{

newZ();

}

}

Choices:

A.Z

B.YZ

C.XYZ

D.YXYZ

简答题

18:

swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上?

19:

StaticInnerClass和InnerClass的不同,说得越多越好。

20:

请说出你所知道的线程同步的方法。

21:

一堆数在一个集合中,总共2n个,问如何将这些数分成A,B两分,每分n个,要求A中的数均小于B中的数,需要考虑时间复杂度。

22:

package test;  

public class FatherClass  

{  

public FatherClass()  

{  

System.out.println("FatherClass Create");  

}  

}  

子类:

  

package test;  

import test.FatherClass;  

public class ChildClass extends FatherClass  

{  

public ChildClass()  

{  

System.out.println("ChildClass Create");  

}  

public static void main(String[] args)  

{  

FatherClass fc = new FatherClass();  

ChildClass cc = new ChildClass();  

}  

}  

输出结果:

   

packagetest;

publicclassFatherClass

{

publicFatherClass()

{

Sy

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1