求学资讯 JAVA培训 提问
JAVA培训 > 历年真题

JAVA认证SCJP认证真题及答案(14)

来源:用户上传 上传用户:zhongzhanen 发布时间:2017-12-28

导读:
想要第一时间获得JAVA考试报考信息,想要充分利用各种精华资讯资源备考,想要海量高质量、高含金量的习题练习,关注“求学快递网”公众号,你不能错过的考试利器!

  QUESTION NO 126

  Given:

  1. public class OuterClass {

  2. private double d1 1.0;

  3. //insert code here

  4. }

  You need to insert an inner class declaration at line2. Which two inner class declarations are valid?

  (Choose Two)

  A. static class InnerOne {

  public double methoda() {return d1;}

  }

  B. static class InnerOne {

  static double methoda() {return d1;}

  }

  C. private class InnerOne {

  public double methoda() {return d1;}

  }

  D. protected class InnerOne {

  static double methoda() {return d1;}

  }

  E. public abstract class InnerOne {

  public abstract double methoda();

  }

  Answer: C, E

  QUESTION NO 127

  Which two declarations prevent the overriding of a method? (Choose Two)

  A. Final void methoda() {}

  B. Void final methoda() {}

  C. Static void methoda() {}

  D. Static final void methoda() {}

  E. Final abstract void methoda() {} www.ExamW.CoM

  Answer: A, D

  QUESTION NO 128

  Given:

  1. public class Test {

  2. public static void main (String args) {

  3. class Foo {

  4. public int i = 3;

  5. }

  6. Object o = (Object) new Foo();

  7. Foo foo = (Foo)o;

  8. System.out.printIn(foo. i);

  9. }

  10. }

  What is the result?

  A. Compilation will fail.

  B. Compilation will succeed and the program will print “3”

  C. Compilation will succeed but the program will throw a ClassCastException at line 6.

  D. Compilation will succeed but the program will throw a ClassCastException at line 7.

  Answer: B

  QUESTION NO 129

  Which two create an instance of an array? (Choose Two)

  A. int ia = new int [15];

  B. float fa = new float [20];

  C. char ca = “Some String”;

  D. Object oa = new float[20];

  E. Int ia = (4, 5, 6) (1, 2, 3)

  Answer: A, D

  QUESTION NO 130

  Given:

  1. public class ExceptionTest {

  2. class TestException extends Exception {}

  3. public void runTest () throws TestException {}

  4. public void test () /* Point X*/ {

  5. runTest ();

  6. }

  7. }

  At point X on line 4, which code can be added to make the code compile?

  A. Throws Exception.

  B. Catch (Exception e).

  C. Throws RuntimeException.

  D. Catch (TestException e).

  E. No code is necessary.

  Answer: B

声明:本站为免费网络服务提供商,网站所有信息均为用户自行发布并由用户承担相应法律责任,本站不对其真实性及合法性负责,如涉及侵权或者信息违法,请你及时与本站联系删除。

阅读 1080 举报

相关推荐
评论0

当前没有评论内容

发表评论 0条评论
41
微博
QQ
QQ空间
微信
取消