java工程师笔试题

时间:2021-02-10 15:14:39 面试笔试 我要投稿

java工程师笔试题

  选择题

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 prevents 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个子阶段,以下哪一个是正常的开发顺序?

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

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

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

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

  9:

  what happens when you try to compile and run the following program?

  class mystery{

  string s;

  public static void main(string[] args){

  mystery m=new mystery();

  m.go();

  }

  void mystery(){

  s=”constructor”;

  }

  void go(){

  system.out.println(s);

  }

  }

  what happens when you try to compile and run the following program?

  class mystery{

  string s;

  public static void main(string[] args){

  mystery m=new mystery();

  m.go();

  }

  void mystery(){

  s=”constructor”;

  }

  void go(){

  system.out.println(s);

  }

  }

  a.this code compliles but throws an exception at runtime

  b.this code runs but nothing appears in the standard output

  c.this code runs and “constructor” in the standard output

  d.this code runs and writes ”null” in the standard output

  10:

  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?

  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?

  a.when compile, some error will occur.

  b.when run, some error will occur.

  c.output is zero.

  d.output is null.

  11:

  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?

  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?

  a.just after line 5.

  b.just after line 6

  c.just after line 7(that is,as the method returns)

  d.never in this method

  12:

  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:

  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:

  a.prints : 2

  b.prints : 3

  c.prints : 7

  d.prints : 8

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

  a=1;

  b=10;

  do

  {

  b-=a;

  a++;

  } while (b—<0);

  a.9

  b.-2

  c.-1

  d.8

  14:设有变量说明语句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(" ");

  a.**0**

  b.**0****2**

  c.**0****1****2**

  d.有语法错误

  15:关于垃圾收集的哪些叙述是对的。

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

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

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

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

  简答题

  16:请设计一个java程序,程序中要进行数组操作和除法操作,要求对所设计的`程序可能出现的异常进行处理。

  17:说明jsp中errorpage的作用,应用范围。

  18:在一个文件中有 10g 个整数,乱序排列,要求找出中位数。内存限制为 2g。只写出思路即可。

  19:swtich是否能作用在byte上,是否能作用在long上,是否能作用在string上?

  20:请指出下面程序中的错误:

  class father

  {

  private int age;

  public void setage(int a)

  {

  this.age = a;

  }

  public int getage()

  {

  return age;

  }

  public void disp()

  {

  system.out.println("age is " + age);

  }

  }

  class son extends father

  {

  string name;

【java工程师笔试题】相关文章:

java英文面试笔试题03-19

java面试笔试题分享03-11

2017java笔试题及答案02-18

java程序员面试笔试试题03-11

工程师面试笔试题03-19

2017年java中高级笔试面试题及答案02-22

网络工程师面试笔试题03-09

java面试最常见问题10-27

java招聘面试常见问题10-27

Java找工作经验心得06-27