目前本站已有 十几万 份求职资料啦!


思迁数码科技招聘Java软件工程师笔试真题

12-17 15:54:20 来源:http://www.qz26.com 笔试题目   阅读:8970
导读:System.out.println(i);}public void methodB(){System.out.println("The value must not be negative");}public static void main(String args[]){AssertTest test = new AssertTest();test.methodA(-10);}}What will happen when you attempt to compile and run the following code?(Assume that the code is compiled and run with assertions enabled.)public class AssertTest{public void methodA(int i){assert i >= 0 : methodB();System.out.println(i);}public void met
思迁数码科技招聘Java软件工程师笔试真题,标签:银行笔试题目,企业笔试题目,http://www.qz26.com

  System.out.println(i);

  }

  public void methodB(){

  System.out.println("The value must not be negative");

  }

  public static void main(String args[]){

  AssertTest test = new AssertTest();

  test.methodA(-10);

  }

  }

  What will happen when you attempt to compile and run the following code?

  (Assume that the code is compiled and run with assertions enabled.)

  public class AssertTest{

  public void methodA(int i){

  assert i >= 0 : methodB();

  System.out.println(i);

  }

  public void methodB(){

  System.out.println("The value must not be negative");

  }

  public static void main(String args[]){

  AssertTest test = new AssertTest();

  test.methodA(-10);

  }

  }

  A.it will print -10

  B.it will result in AssertionError showing the message-“the value must not be negative”.

  C.the code will not compile.

  D.None of these.

  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:假定a和b为int型变量,则执行下述语句组后,b的值为

  a=1;

  b=10;

  do

  {

  b-=a;

  a++;

  } while (b--<0);

  A.9

  B.-2

  C.-1

  D.8

  9:

  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

上一页  [1] [2] [3]  下一页


Tag:笔试题目银行笔试题目,企业笔试题目求职笔试面试 - 笔试题目
【字号: 】 【打印】 【关闭
最新更新
推荐热门
联系我们 | 网站地图 | 财务资料 | 范文大全 | 求职简历 | 财会考试 | 成功励志
Copyright 二六求职资料网 All Right Reserved.
1 2 3 4 5 6 7 8 9 10