易搜题 > 资格证大类 > 计算机编程 > 问题详情
问题详情

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 16. }   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; }

未找到的试题在搜索页框底部可快速提交,在会员中心"提交的题"查看可解决状态。 收藏该题
查看答案

相关问题推荐

  • What can directly access and change the value of the variable name?()

    A、 any class

    B、 only the Target class

    C、 any class in the test package

    D、 any class that extends Target

  • int I=1, j=0   switch(i) {   case 2:   j+=6;   case 4:   j+=1;    default:    j +=2;   case 0:   j +=4;   }   What is the value of j at line 16?()

    A

     0

    B

     1

    C

     2

    D

     4

    E

     6

  • public class ForBar {   public static void main(String args) {   int i = 0, j = 5;   tp: for (;;) {   i ++;   for(;;)   if(i > --j) break tp;   }   system.out.printIn(“i = ” + i + “, j = “+ j);   }   }   What is the result? () 

    A、 The program runs and prints “i=1, j=0”

    B、 The program runs and prints “i=1, j=4”

    C、 The program runs and prints “i=3, j=4”

    D、 The program runs and prints “i=3, j=0”

    E、 An error at line 4 causes compilation to fail.

    F、 An error at line 7 causes compilation to fail.

  • class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()  

    A、 Base

    B、 BaseBase

    C、 Compilation fails.

    D、 The code runs with no output.

    E、 An exception is thrown at runtime.

  • Runnable r = new Runnable() {  public void run() {  System.out.print(”Cat”);  }  };  Threadt=new Thread(r) {  public void run() {  System.out.print(”Dog”);  }  };  t.start();  What is the result?() 

    A、 Cat

    B、 Dog

    C、 Compilation fails.

    D、 The code runs with no output.

    E、 An exception is thrown at runtime.

联系客服 会员中心
TOP