SCJP程序员认证考试

单选题1. interface foo {  2. int k = 0;  3. } 4.    5. public class test implements Foo (  6. public static void main(String args[]) (  7. int i;  8. Test test = new test ();  9. i= test.k;  10.i= Test.k;  11.i= Foo.k;  12.)  13.)  14.        What is the res

题目
单选题
1. interface foo {  2. int k = 0;  3. } 4.    5. public class test implements Foo (  6. public static void main(String args[]) (  7. int i;  8. Test test = new test ();  9. i= test.k;  10.i= Test.k;  11.i= Foo.k;  12.)  13.)  14.        What is the result?()
A

 Compilation succeeds.

B

 An error at line 2 causes compilation to fail.

C

 An error at line 9 causes compilation to fail.

D

 An error at line 10 causes compilation to fail.

E

 An error at line 11 causes compilation to fail.

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() 

  • A、 Line 4 of class Target can be changed to return i++;
  • B、 Line 2 of class Target can be changed to private int i = 1;
  • C、 Line 3 of class Target can be changed to private int addOne() {
  • D、 Line 2 of class Target can be changed to private Integer i = 0;

正确答案:D

第2题:

1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()

  • A、 The program runs and prints “0”
  • B、 The program runs and prints “1”
  • C、 The program runs but aborts with an exception.
  • D、 An error “possible undefined variable” at line 4 causes compilation to fail.
  • E、 An error “possible undefined variable” at line 9 causes compilation to fail.

正确答案:B

第3题:

Given:1.<%int[]nums={42,420,4200};2.request.setAttribute("foo",nums);%>3.${5+3lt6}4.${requestScope[’foo’][0]ne10div0}5.${10div0}Whatistheresult?()

A.Truetrue

B.Falsetrue

C.Falsetrue0

D.TruetrueInfinity

E.FalsetrueInfinity


参考答案:E

第4题:

Given: 1.<% int[] nums = {42,420,4200}; 2.request.setAttribute("foo", nums); %> 3.${5 + 3 lt 6} 4.${requestScope[’foo’][0] ne 10 div 0} 5. ${10 div 0} What is the result?()

  • A、True true
  • B、False true
  • C、False true 0
  • D、True true Infinity
  • E、False true Infinity

正确答案:E

第5题:

Given:  1.  public interface Foo {  2.  int k = 4:  3.  }   Which three are equivalent to line 2?()

  • A、 final int k = 4:
  • B、 public int k = 4:
  • C、 static int k = 4:
  • D、 private int k = 4:
  • E、 abstract int k = 4:
  • F、 volatile int k = 4:
  • G、 transient int k = 4:
  • H、 protected int k = 4:

正确答案:A,B,C

第6题:

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

  • A、 Compilation will succeed for all classes and interfaces.
  • B、 Compilation of class C will fail because of an error in line 2.
  • C、 Compilation of class C will fail because of an error in line 6.
  • D、 Compilation of class AImpl will fail because of an error in line 2.

正确答案:C

第7题:

public interface Foo {  int k = 4; 3. }  Which three are equivalent to line 2?()

  • A、 final int k = 4;
  • B、 public int k = 4;
  • C、 static int k = 4;
  • D、 abstract int k = 4;
  • E、 volatile int k = 4;
  • F、 protected int k = 4;

正确答案:A,B,C

第8题:

public interface Foo{  int k = 4;  }   Which three are equivalent to line 2?()   

  • A、 Final int k = 4;
  • B、 Public int k = 4;
  • C、 Static int k = 4;
  • D、 Private int k = 4;
  • E、 Abstract int k = 4;
  • F、 Volatile int k = 4;

正确答案:A,B,C

第9题:

1. class SuperFoo {  2. SuperFoo doStuff(int x) {  3. return new SuperFoo(); 4. }  5. }  6.  7. class Foo extends SuperFoo {  8. //insert code here  9. }   下面哪三项分别插入到第8行,可以编译?()

  • A、int doStuff() { return 42; }
  • B、int doStuff(int x) { return 42; }
  • C、Foo doStuff(int x) { return new Foo(); }
  • D、SuperFoo doStuff(int x) { return new Foo(); }

正确答案:A,C,D

第10题:

1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()

  • A、 0
  • B、 3
  • C、 4
  • D、 5
  • E、 The code will not compile.

正确答案:E

更多相关问题