浙大网新中研软件开发工程师笔试题

时间:2022-11-13 05:59:09 笔试题目 我要投稿
  • 相关推荐

浙大网新中研软件开发工程师笔试题

  选择题

浙大网新中研软件开发工程师笔试题

  1: Consider the class hierarchy shown below:

  ——————————————————————–

  class FourWheeler implements DrivingUtilities

  class Car extends FourWheeler

  class Truck extends FourWheeler

  class Bus extends FourWheeler

  class Crane extends FourWheeler

  ———————————————————————-

  Consider the following code below:

  1.DrivingUtilities du;

  2.FourWheeler fw;

  3.Truck myTruck = new Truck();

  4.du = (DrivingUtilities)myTruck;

  5.fw = new Crane();

  6.fw = du;

  Which of the statements below are true?

  Choices:

  A.Line 4 will not compile because an interface cannot refer to an object.

  B.The code will compile and run.

  C.The code will not compile without an explicit cast at line 6, because going down the hierarchy without casting is not allowed.

  D.The code will compile if we put an explicit cast at line 6 but will throw an exception at runtime.

  2: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

  3:

  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

  4:

  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

  5:

  What will be the result of executing the following code?

  public static void main(String args[])

  {

  char digit = ‘a’;

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

  {

  switch (digit)

  {

  case ‘x’ :

  {

  int j = 0;

  System.out.println(j);

  }

  default :

  {

  int j = 100;

  System.out.println(j);

  }

  }

  }

  int i = j;

  System.out.println(i);

  }

  Choices:

  What will be the result of executing the following code?

  public static void main(String args[])

  {

  char digit = ‘a’;

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

  {

  switch (digit)

  {

  case ‘x’ :

  {

  int j = 0;

  System.out.println(j);

  }

  default :

  {

  int j = 100;

  System.out.println(j);

  }

  }

  }

  int i = j;

  System.out.println(i);

  }

  Choices:

  A.100 will be printed 11 times.

  B.The code will not compile because the variable i cannot be declared twice within the main() method.

  C.The code will not compile because the variable j cannot be declared twice within the switch statement.

  D.None of these.

  6:

  What results from attempting to compile and run the following code?

  public class Ternary

  {

  public static void main(String args[])

  {

  int a = 5;

  System.out.println(“Value is - ” + ((a < 5) ? 9.9 : 9));

  }

  }

  Choices:

  What results from attempting to compile and run the following code?

  public class Ternary

  {

  public static void main(String args[])

  {

  int a = 5;

  System.out.println(“Value is - ” + ((a < 5) ? 9.9 : 9));

  }

  }

  Choices:

  A.prints: Value is - 9

  B.Compilation error

  C. prints: Value is - 5

  D.None of these

  7:使用 JDBC 可以做到的是

  把二进制代码传送到任何关系数据库中

  把 Java 源代码传送到任何关系数据库中

  把表单信息传送到任何关系数据库中

  很容易地把 SQL 语句传送到任何关系数据库中

  8:Which fragments are not correct in Java source file?

  A.package testpackage; public class Test{//do something…}

  B.import java.io.*; package testpackage; public class Test{// do something…}

  C.import java.io.*; class Person{// do something…} public class Test{// do something…}

  D.import java.io.*; import java.awt.*; public class Test{// do something…}

  9:Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke.

  A.int count = args.length;

  B.int count = args.length-1;

  C.int count=0; while(args[count]!=null) count++;

  D.int count=0;while (!(args[count].equals(“”))) count++;

  10:

  1. public class X {

  2. public object m () {

  3. object o = new float (3.14F);

  4. object [] oa = new object [1];

  5. oa[0]= o;

  6. o = null;

  7. oa[0] = null;

  8.return o;

  9. }

  10.}

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

  1. public class X {

  2. public object m () {

  3. object o = new float (3.14F);

  4. object [] oa = new object [1];

  5. oa[0]= o;

  6. o = null;

  7. oa[0] = null;

  8.return o;

  9. }

  10.}

  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

  D.Just after line 8(that is, as the method returns)

  11:

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

  12:

  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”?

  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”?

  A.x<4

  B.x>4

  C.x>9

  D.None

  13:

  What will be the result of executing the following code?

  // Filename; SuperclassX.java

  package packageX;

  public class SuperclassX

  {

  protected void superclassMethodX()

  {

  }

  int superclassVarX;

  }

  // Filename SubclassY.java

  1.package packageX.packageY;

  2.

  3.public class SubclassY extends SuperclassX

  4.{

  5.SuperclassX objX = new SubclassY();

  6.SubclassY objY = new SubclassY();

  7.void subclassMethodY()

  8.{

  9.objY.superclassMethodX();

  10.int i;

  11.i = objY.superclassVarX;

  12.}

  13.}

  Choices:

  What will be the result of executing the following code?

  // Filename; SuperclassX.java

  package packageX;

  public class SuperclassX

  {

  protected void superclassMethodX()

  {

  }

  int superclassVarX;

  }

  // Filename SubclassY.java

  1.package packageX.packageY;

  3.public class SubclassY extends SuperclassX

  4.{

  5.SuperclassX objX = new SubclassY();

  6.SubclassY objY = new SubclassY();

  7.void subclassMethodY()

  8.{

  9.objY.superclassMethodX();

  10.int i;

  11.i = objY.superclassVarX;

  12.}

  13.}

  Choices:

  A.Compilation error at line 5

  B.Compilation error at line 9

  C.Runtime exception at line 11

  D.None of these

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

  a=1;

  b=10;

  do

  {

  b-=a;

  a++;

  } while (b–<0);

  A.9

  B.-2

  C.-1

  D.8

  15:Which statement about the garbage collection mechanism are true?

  A.Garbage collection require additional programe code in cases where multiple threads are running.

  B.The programmer can indicate that a reference through a local variable is no longer of interest.

  C.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.

  D.The garbage collection mechanism can free the memory used by Java Object at explection time.

  简答题

  16:tomcat中,什么是DefaultServlet?他的功能是什么?

  17:

  class Something {

  int I;

  public void doSomething() {

  System.out.println(“I = ” + i);

  }

  }

  代码是否有错?为什么。

  class Something {

  int I;

  public void doSomething() {

  System.out.println(“I = ” + i);

  }

  }

  代码是否有错?为什么。

  18:如何给weblogic指定大小的内存?

  19:写一个程序,把一个100以内的自然数分解因数。(自然数分解因数就是将一个自然数分解为几个素数的乘积,提示,由于该数不是很大,所以可以将质数保存在数组中,以加快计算速度)

  20:将一个1M-10M的文件,逆序存储到另一个文件,就是前一个文件的最后一个字符存到新文件的第一个字符,以此类推。

  21:Is Tomcat faster than serving static HTML pages than Apache httpd?

  22:任何一个自然数m的立方均可写成m个连续奇数之和。例如:

  1^3=1

  2^3=3+5

  3^3=7+9+11

  4^3=13+15+17+19

  编程实现:输入一自然数n,求组成n3的n个连续奇数。

  23:如何判定两条线段是否相交?

  24:How to open a host and send a stream throught net in TCP/ IP using Java

  25:Java中异常处理有什么优点?

【浙大网新中研软件开发工程师笔试题】相关文章:

盛大网络策划专业笔试题07-31

中兴2015笔试题08-02

迅雷2011.10.21笔试题08-10

大唐移动测试工程师笔经,笔试题目分享11-21

广联达软件开发笔试题11-21

关于研华的笔试题分享11-21

笔经:加强型试题07-22

新思笔试题03-23

海尔04年笔试题及答案07-31

新媒体运营笔试题09-25