java软件开发工程师笔试题

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

java软件开发工程师笔试题

  选择题

java软件开发工程师笔试题

  1:

  in the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:

  1.public class test {

  2. public static void main (string args []) {

  3. employee e = new employee("bob", 48);

  4. e.calculatepay();

  5. system.out.println(e.printdetails());

  6. e = null;

  7. e = new employee("denise", 36);

  8. e.calculatepay();

  9. system.out.println(e.printdetails());

  10. }

  11.}

  only one:

  in the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:

  1.public class test {

  2. public static void main (string args []) {

  3. employee e = new employee("bob", 48);

  4. e.calculatepay();

  5. system.out.println(e.printdetails());

  6. e = null;

  7. e = new employee("denise", 36);

  8. e.calculatepay();

  9. system.out.println(e.printdetails());

  10. }

  11.}

  only one:

  a.line 10

  b.line 11

  c.line 7

  d.line 8

  2:exhibit :

  1. public class test (

  2. private static int j = 0;

  3.

  4. private static boolean methodb(int k) (

  5. j += k;

  6. return true;

  6. )

  7.

  8. public static void methoda(int i) {

  9. boolean b:

  10. b = i < 10 | methodb (4);

  11. b = i < 10 || methodb (8);

  12. )

  13.

  14. public static void main (string args[] } (

  15. methoda (0);

  16. system.out.printin(j);

  17. )

  18. )

  what is the result?

  a.the program prints “0”

  b.the program prints “4”

  c.the program prints “8”

  d.the program prints “12”

  3:what is written to the standard output given the following statement:system.out.println(4|7);

  select the right answer:

  a.4

  b.5

  c.6

  d.7

  4:

  select valid identifier of java:

  select valid identifier of java:

  a.%passwd

  b.3d_game

  c.$charge

  d.this

  5:设有变量说明语句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.有语法错误

  6:in the following pieces of code, which one will compile without any error?

  a.stringbuffer sb1 = "abcd";

  b.boolean b = new boolean("abcd");

  c.c: byte b = 255;

  d.float fl = 1.2;

  7:

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

  public class throwsdemo

  {

  static void throwmethod()

  {

  system.out.println("inside throwmethod.");

  throw new illegalaccessexception("demo");

  }

  public static void main(string args[])

  {

  try

  {

  throwmethod();

  }

  catch (illegalaccessexception e)

  {

  system.out.println("caught " + e);

  }

  }

  }

  choices:

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

  public class throwsdemo

  {

  static void throwmethod()

  {

  system.out.println("inside throwmethod.");

  throw new illegalaccessexception("demo");

  }

  public static void main(string args[])

  {

  try

  {

  throwmethod();

  }

  catch (illegalaccessexception e)

  {

  system.out.println("caught " + e);

  }

  }

  }

  choices:

  a.compilation error

  b.runtime error

  c.compile successfully, nothing is printed.

  d.inside throwmethod. followed by caught:java.lang.illegalaccessexcption: demo

  8:which of the following statements are not legal?

  a.long l = 4990;

  b.int i = 4l;

  c.double d = 34.4;

  d.double t = 0.9f.

  9:

  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.

  10:下面关于变量及其范围的陈述哪些是错的。

  a.实例变量是类的成员变量。

  b.实例变量用关键字static声明。

  c.在方法中定义的局部变量在该方法被执行时创建

  d.局部变量在使用前必须被初始化。

  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:

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

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

  a.assert countrycode != null;

  b.assert countrycode != null : "country code can not be null" ;

  c.assert cctld != null : "no country code data is available";

  d.assert cctld : "no country code data is available";

  13:

  give the following code:

  public class example{

  public static void main(string args[] ){

  int l=0;

  do{

  system.out.println(“doing it for l is:”+l);

  }while(—l>0)

  system.out.println(“finish”);

  }

  }

  which well be output:

  give the following code:

  public class example{

  public static void main(string args[] ){

  int l=0;

  do{

  system.out.println(“doing it for l is:”+l);

  }while(—l>0)

  system.out.println(“finish”);

  }

  }

  which well be output:

  a.doing it for l is 3

  b.doing it for l is 1

  c.doing it for l is 2

  d.doing it for l is 0

  14:which statements about java code security are not true?

  a.the bytecode verifier loads all classes needed for the execution of a program.

  b.executing code is performed by the runtime interpreter.

  c.at runtime the bytecodes are loaded, checked and run in an interpreter.

  d.the class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.

  15:a class design requires that a member variable should be accessible only by same package, which modifer word should be used?

  a.protected

  b.public

  c.no modifer

  d.private

  16:character流与byte流的区别是

  a.每次读入的字节数不同

  b.前者带有缓冲,后者没有

  c.前者是块读写,后者是字节读写

  d.二者没有区别,可以互换使用

  简答题

  17:找出两个字符串中最大子字符串,如"abractyeyt","dgdsaeactyey"的最大子串为"actyet"

  18:假设你有一个用1001个整数组成的数组,这些整数是任意排列的',但是你知道所有的整数都在1到1000(包括1000)之间。此外,除一个数字出现两次外,其他所有数字只出现一次。假设你只能对这个数组做一次处理,用一种算法找出重复的那个数字。如果你在运算中使用了辅助的存储方式,那么你能找到不用这种方式的算法吗?

  19:到底在哪里使用cascade="..."?

  20:使用tomcat部署应用程序 遇到过java.lang.outofmemoryerror 吗?如何解决的。

  21:请写一个java程序实现数据库缓冲池的功能?

  22:有200个正整数,且每个数均在1000至9999之间。请编制函数,其函数的功能是:要求按每个数的后三位的大小进行升序排列,然后取出满足此条件的前10个数依次存入数组bb中,如果后三位的数值相等,则按原先的数值进行降序排列。

  23:anonymous inner class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)?

  24:找出字符串a中包含的字符可以进行的所有不同组合。例如:abccd中,ab,ac,bc,cc,abd等都是可能的组合。

  25:下面的代码在绝大部分时间内都运行得很正常,请问在什么情况下会出现问题?问题的根源在哪里?

  import java.util.linkedlist;

  public class stack {

  linkedlist list = new linkedlist();

  public synchronized void push(object x) {

  synchronized(list) {

  list.addlast( x );

  notify();

  }

  }

  public synchronized object pop()

  throws exception {

  synchronized(list) {

  if( list.size() <= 0 ) {

  wait();

  }

  return list.removelast();

  }

  }

  }

【java软件开发工程师笔试题】相关文章:

java英文面试笔试题03-19

java面试笔试题分享03-11

2017java笔试题及答案02-18

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

工程师面试笔试题03-19

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

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

Java找工作经验心得06-27

java面试最常见问题10-27

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