上大学网 > 招聘笔试题 > 正文

Java工程师笔试题和面试题答案

时间:招聘笔试题 上大学网

  选择题

  1:Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body?

  A.synchronized

  B.abstract

  C.final

  D.static

  2:

  Give the following java source fragement:

  //point x

  public class Interesting{

  //do something

  }

  Which statement is correctly Java syntax at point x?

  Give the following java source fragement:

  //point x

  public class Interesting{

  //do something

  }

  Which statement is correctly Java syntax at point x?

  A.public class MyClass{//do other thing…}

  B.static int PI=3.14

  C.class MyClass{//do something…}

  D.none

  3:

  What is the result when you compile and run the following code?

  public class Test

  {

  public void method()

  {

  for(int i = 0; i < 3; i++)

  {

  System.out.print(i);

  }

  System.out.print(i);

  }

  }

  Choices:

  What is the result when you compile and run the following code?

  public class Test

  {

  public void method()

  {

  for(int i = 0; i < 3; i++)

  {

  System.out.print(i);

  }

  System.out.print(i);

  }

  }

  Choices:

  A.0122

  B.0123

  C.Compilation error

  D.None of these

  4: Which of the following statements are true?

  A.The automatic garbage collection of the JVM Pvents programs from ever running out of memory

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

  C.Garbage collection is platform independent

  D.An object becomes eligible for garbage collection when all references denoting it are set to null.

  5:

  Give the following method:

  public void method( ){

  String a,b;

  a=new String(“hello world”);

  b=new String(“game over”);

  System.out.println(a+b+”ok”);

  a=null;

  a=b;

  System.out.println(a);

  }

  In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.

  Give the following method:

  public void method( ){

  String a,b;

  a=new String(“hello world”);

  b=new String(“game over”);

  System.out.println(a+b+”ok”);

  a=null;

  a=b;

  System.out.println(a);

  }

  In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.

  A.before line 5

  B.before line 6

  C.before line 7

  D.before line 9

  6:

  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?

  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?

  A.Change private int x to public int x

  B.change private int x to static int x

  C.Change private int x to protected int x

  D.change private int x to final int x

  7:

  Given the following class definition:

  class A{

  protected int i;

  A(int i){

  this.i=i;

  }

  }

  which of the following would be a valid inner class for this class?

  Select valid answer:

  Given the following class definition:

  class A{

  protected int i;

  A(int i){

  this.i=i;

  }

  }

  which of the following would be a valid inner class for this class?

  Select valid answer:

  A.class B{ }

  B.class B extends A{ }

  C.class B extends A{ B(){System.out.println(“i=”+i);} }

  D.class B{ class A{} }

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

中国点击率最高的一篇文章 !