java软件开发工程师笔试题

时间:2022-10-26 23:04:48 笔试题目 我要投稿
  • 相关推荐

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-29

java软件开发工程师简历范文12-06

Java软件开发工程师个人简历模板02-02

java软件开发工程师个人简历范文03-09

Java软件开发工程师个人简历模板05-28

java中级工程师面试题03-30

java软件开发简历11-30

Java软件开发工程师个人简历范文模板06-03

电子商务java软件开发工程师简历范文03-11

中兴Java Web开发工程师笔试题及答案02-10