单选题1. abstract class AbstractIt {  2. abstract float getFloat();  3. }  4. public class AbstractTest extends AbstractIt {  5. private float f1 = 1.0f;  6. private float getFloat() { return f1; }  7. }  What is the result?()A  Compilation succeeds.B  An ex

题目
单选题
1. abstract class AbstractIt {  2. abstract float getFloat();  3. }  4. public class AbstractTest extends AbstractIt {  5. private float f1 = 1.0f;  6. private float getFloat() { return f1; }  7. }  What is the result?()
A

 Compilation succeeds.

B

 An exception is thrown.

C

 Compilation fails because of an error at line 2.

D

 Compilation fails because of an error at line 6.

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

第1题:

1. interface DoStuff2 {  2. float getRange(int low, int high); }  3.  4. interface DoMore {  5. float getAvg(int a, int b, int c); }  6.  7. abstract class DoAbstract implements DoStuff2, DoMore { }  8.  9. class DoStuff implements DoStuff2 {  10. public float getRange(int x, int y) { return 3.14f; } }  11.  12. interface DoAll extends DoMore {  13. float getAvg(int a, int b, int c, int d); }  What is the result?() 

  • A、 The file will compile without error.
  • B、 Compilation fails. Only line 7 contains an error.
  • C、 Compilation fails. Only line 12 contains an error.
  • D、 Compilation fails. Only line 13 contains an error.
  • E、 Compilation fails. Only lines 7 and 12 contain errors.
  • F、 Compilation fails. Only lines 7 and 13 contain errors.
  • G、 Compilation fails. Lines 7, 12, and 13 contain errors.

正确答案:A

第2题:

Given:  1. public class Method Over {  2. public void set Var (int a, int b, float c) {  3. }  4. }   Which two overload the set Var method()?

  • A、 private void set Var(int a, float c, int b) {}
  • B、 protected void set Var(int a, int b, float c) {}
  • C、 public int set Var(int a, float c, int b) {return a:}
  • D、 public int set Var(int a, int b, float c) {return a:}
  • E、 protected float set Var(int a, int b, float c) {return c:}

正确答案:A,C

第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题:

class BaseClass{   private float x= 1.0f;   protected void setVar (float f) {x = f;}   }   class SubClass exyends BaseClass {   private float x = 2.0f;   //insert code here  8. }   Which two are valid examples of method overriding?()

  • A、 Void setVar(float f) {x = f;}
  • B、 Public void setVar(int f) {x = f;}
  • C、 Public void setVar(float f) {x = f;}
  • D、 Public double setVar(float f) {x = f;}
  • E、 Public final void setVar(float f) {x = f;}
  • F、 Protected float setVar() {x=3.0f; return 3.0f; }

正确答案:C,E

第5题:

现有:  1. abstract class Color2  {      2.    //insert code here      3.  }      4.  5. public class Blue2 extends Color2  {  6.public  String getRGB()  {  return  "blue";  }      7.  }  和4个声明:  public abstract  String getRGB();     abstract  String getRGB();  private abstract  String getRGB();      protected abstract String getRGB();  分别插入到第2行,有多少行可以编译?()     

  • A、  0
  • B、  1
  • C、  2
  • D、  3

正确答案:D

第6题:

1. abstract class AbstractIt {  2. abstract float getFloat();  3. }  4. public class AbstractTest extends AbstractIt {  5. private float f1 = 1.0f;  6. private float getFloat() { return f1; }  7. }  What is the result?() 

  • A、 Compilation succeeds.
  • B、 An exception is thrown.
  • C、 Compilation fails because of an error at line 2.
  • D、 Compilation fails because of an error at line 6.

正确答案:D

第7题:

abstract class abstrctIt {   abstract float getFloat ();   }   public class AbstractTest extends AbstractIt {   private float f1= 1.0f;   private float getFloat () {return f1;}   }   What is the result? ()

  • A、 Compilation is successful.
  • B、 An error on line 6 causes a runtime failure.
  • C、 An error at line 6 causes compilation to fail.
  • D、 An error at line 2 causes compilation to fail.

正确答案:C

第8题:

1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()  

  • A、 public void getNum(){}
  • B、 public void getNum(double d){}
  • C、 public float getNum() { return 4.0f; }
  • D、 public double getNum(float d) { return 4.0d; }

正确答案:A

第9题:

class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()        

  • A、 Void setVar(float f) {x = f;}
  • B、 Public void setVar(int f) {x = f;}
  • C、 Public void setVar(float f) {x = f;}
  • D、 Public double setVar(float f) {x = f;}
  • E、 Public final void setVar(float f) {x = f;}
  • F、 Protected float setVar() {x=3.0f; return 3.0f; }

正确答案:C,E

第10题:

ClassOne.java: 1. package com.abe.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() { return var; } 5. } ClassTest.java: 1. package com.abe.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[] args) { 5. char a = new ClassOne().getVar();6. char b = new ClassTest().getVar(); 7. } 8. } What is the result?()

  • A、 Compilation fails.
  • B、 Compilation succeeds and no exceptions are thrown.
  • C、 An exception is thrown at line 5 in ClassTest.java.
  • D、 An exception is thrown at line 6 in ClassTest.java.

正确答案:A

更多相关问题