SCJP程序员认证考试

多选题public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()Astatic class InnerOne {  public double methoda() {return d1;}  }Bstati

题目
多选题
public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()
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();  }

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

第1题:

Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?()    public class Qf575 {   // insert declaration of a native method here   }  

  • A、native public void setTemperature(int kelvin);
  • B、private native void setTemperature(int kelvin);
  • C、protected int native getTemperature();
  • D、public abstract native void setTemperature(int kelvin);
  • E、native int setTemperature(int kelvin) {}

正确答案:A,B

第2题:

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

第3题:

1. class BaseClass {  2. private float x = 1.of;  3. protected float getVar() { return x; }  4. }  5. class SubClass extends BaseClass {  6. private float x = 2.Of;  7. // insert code here 8. }   Which two are valid examples of method overriding when inserted at line 7?() 

  • A、 float getVar() { return x; }
  • B、 public float getVar() { return x; }
  • C、 public double getVar() { return x; }
  • D、 protected float getVar() { return x; }
  • E、 public float getVar(float f) { return f; }

正确答案:B,D

第4题:

Which the following two statements are true?()

  • A、 An inner class may be declared as static.
  • B、 An anonymous inner class can be declared as public.
  • C、 An anonymous inner class can be declared as private.
  • D、 An anonymous inner class can extend an abstract class.
  • E、 An anonymous inner class can be declared as protected.

正确答案:A,D

第5题:

10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()

  • A、 double getSalesAmount() { return 1230.45; }
  • B、 public double getSalesAmount() { return 1230.45; }
  • C、 private double getSalesAmount() { return 1230.45; }
  • D、 protected double getSalesAmount() { return 1230.45; }

正确答案:B,D

第6题:

class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()

  • A、 int foo() { /* more code here */ }
  • B、 void foo() { /* more code here */ }
  • C、 public void foo() { /* more code here */ }
  • D、 private void foo() { /* more code here */ }
  • E、 protected void foo() { /* more code here */ }

正确答案:B,C,E

第7题:

Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?()   public class Qdd1f {   public long sum(long a, long b) {  return a + b;  }   // insert new method declaration here  }  

  • A、public int sum(int a, int b) { return a + b; }
  • B、public int sum(long a, long b) { return 0; }
  • C、abstract int sum();
  • D、private long sum(long a, long b) { return a + b; }
  • E、public long sum(long a, int b) { return a + b; }

正确答案:A,E

第8题:

Which two statements are true?()

  • A、 An inner class may be declared as static.
  • B、 An anonymous inner class can be declared as public.
  • C、 An anonymous inner class can be declared as private.
  • D、 An anonymous inner class can extend an abstract class.
  • E、 An anonymous inner class can be declared as protected.

正确答案:A,D

第9题:

package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? () 

  • A、 An instance of the Inner class can be constructed with “new Outer.Inner ()”
  • B、 An instance of the inner class cannot be constructed outside of package foo.
  • C、 An instance of the inner class can only be constructed from within the outer class.
  • D、 From within the package bar, an instance of the inner class can be constructed with “new inner()”

正确答案:A

第10题:

public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()

  • 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();  }

正确答案:C,E

更多相关问题