中兴软创笔试题三

 

招聘试题3

1.选择题(4′×10)

例题1.(d)

class Parent{

   public  void method1(){   //change here

     System.out.println("Parent's method1()");

   }

  public void method2()

  {

    System.out.println("Parent's method2()");

    method1();

  }

}

class Child extends Parent{

  public void method1(){

    System.out.println("Child's method1()");

  }

  public static void main(String args[]){

  Child p = new Child();//change here

  p.method2();

  }

}

 

Choices:

a. Compile time error

b. Run time error

c. prints : Parent's method2()

          Parent's method1()

d. prints : Parent's method2()

          Child's method1()

 

例题2

  How can you force garbage collection of an object?

  A. Garbage collection cannot be forced

  B. Call System.gc().

  C. Call System.gc(), passing in a reference to the object to be garbage collected.

  D. Call Runtime.gc().

  E. Set all references to the object to new valuesnull, for example.

 

例题3

  Consider the following class:

  1. class Test(int i) {

  2. void test(int i) {

  3. System.out.println(I am an int.);

  4. }

  5. void test(String s) {

  6. System.out.println(I am a string.);

  7. }

  8.

  9. public static void main(String args[]) {

  10. Test t=new Test();

  11. char ch='y';

  12. t.test(ch);

  13. }

  14. }

 

  Which of the statements below is true?(Choose one.)

  A. Line 5 will not compile, because void methods cannot be overridden.

  B. Line 12 will not compile, because there is no version of test() that rakes a char argument.

  C. The code will compile but will throw an exception at line 12.

  D. The code will compile and produce the following output: I am a

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值