SCJP程序员认证考试

单选题10. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25

题目
单选题
10. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25. }  26. }  And:  30. class ClassC {  31. public String value;  32.  33. public String getValue() {  34. value = “ClassB”;  35. return value;  36. }  37. }  Given:  ClassA a = new ClassA();  a.methodA();  What is the result?()
A

 Compilation fails.

B

 ClassC is displayed.

C

 The code runs with no output.

D

 An exception is thrown at runtime.

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() 

  • A、 StackOverflowError
  • B、 NullPointerException
  • C、 NumberFormatException
  • D、 IllegalArgumentException
  • E、 ExceptionlnlnitializerError

正确答案:A

第2题:

Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()

  • A、 abstract public void methoda ();
  • B、 public abstract double inethoda ();
  • C、 static void methoda (double dl) {}
  • D、 public native double methoda () {}
  • E、 protected void methoda (double dl) {}

正确答案:C

第3题:

Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()()

A.

B.

C.

D.

E.

F.


参考答案:A

第4题:

Which will declare a method that forces a subclass to implement it? () 

  • A、 Public double methoda();
  • B、 Static void methoda (double d1) {}
  • C、 Public native double methoda();
  • D、 Abstract public void methoda();
  • E、 Protected void methoda (double d1){}

正确答案:D

第5题:

Which two are valid declarations within an interface definition?() 

  • A、 void methoda();
  • B、 public double methoda();
  • C、 public final double methoda();
  • D、 static void methoda(double d1);
  • E、 protected void methoda(double d1);

正确答案:A,B

第6题:

Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  

  • A、 Abstract public void methoda();
  • B、 Public abstract double methoda();
  • C、 Static void methoda(double d1){}
  • D、 Public native double methoda(){}
  • E、 Protected void methoda(double d1){}

正确答案:C

第7题:

public class TestA{    public void methodA() throws IOException{        //……    } }  public class TestB extends TestA{    public void methodA() throws EOFException{        //……   } }  public class TestC extends TestA{    public void methodA() throws Exception{        //……   } }  当编译类TestC的时候,结果是哪项?() 

  • A、 正常
  • B、 编译错误
  • C、 运行错误
  • D、 以上都不对

正确答案:B

第8题:

下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;

A.CLASS A CLASS B CLASS B CLASS B

B.CLASS A CLASS B CLASS A CLASS B

C.CLASS A CLASS B CLASS B

D.CLASS A CLASS B


正确答案:C

第9题:

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

  • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
  • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
  • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
  • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
  • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
  • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

正确答案:A

第10题:

在接口中以下哪条定义是正确的?()

  • A、void methoda();
  • B、public double methoda();
  • C、public final double methoda();
  • D、static void methoda(double d1);
  • E、protected void methoda(double d1);

正确答案:A,B

更多相关问题