多选题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()?Aprivate void set Var(int a, float c, int b) {}Bprotected void set Var(int a, int b, float c) {}Cpublic int se

题目

多选题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()?Aprivate void set Var(int a, float c, int b) {}Bprotected void set Var(int a, int b, float c) {}Cpublic int set Var(int a, float c, int b) {return a:}Dpublic int set Var(int a, int b, float c) {return a:}Eprotected float set Var(int a, int b, float c) {return c:}


相似考题
更多“多选题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()?Aprivate void set Var(int a, float c, int b) {}Bprotected void set Var(int a, int b, float c) {}Cpublic int se”相关问题
  • 第1题:

    有如下类声明: class MyBASE{ int k; public: void set(int n){k=n;} int get( )const{return k;} }; class MyDERIVED:protected MyBASE{ protected: intj; public: void set(int m,int n){MyBASE::set(m);j=n;} int get( )const{return MyBASE::get( )+j;} }; 则类MyDERIVED中保护的数据成员和成员函数的个数是

    A.4

    B.3

    C.2

    D.1


    正确答案:B
    解析:在保护派生的单继承中,基类的公有数据成员和成员函数在派生类中成为保护成员。

  • 第2题:

    有以下程序:include using namespace std;class A{private: int x,y;public: void se

    有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。

    A.8

    B.4

    C.35

    D.70


    正确答案:A
    解析:本题考核成员对象的应用。类box的成员函数set()为设置对象的坐标值和对象的长、宽值。成员函数setarea返回该对象的面积。程序最后输出为8。

  • 第3题:

    类Test定义如下,将下列哪个方法插入③行处是不合法的( )?

    ① public class Test{

    ② public float Method(float a,float B) { }

    ③ ______

    ④ }

    A.public float Method(float a,float b,float C) { }

    B.public float Method(float c,float d){ }

    C.public int Method(int a,int B) { }private float Method(int a,int b,int C) { }

    D.private float Method(int a,int b,int C) { }


    正确答案:B
    解析:本题主要考查方法重载,方法的重载是指多个方法可以享有相同的名字,但参数的数量或类型必须不相同(采用不同的形式参数列表),选项B不符合方法重载的要求。

  • 第4题:

    下面哪个方法是 public void example(){...} 的重载方法?

    A、private void example( int m){...}

    B、public int example(){...}

    C、public void example2(){...}

    D、public int example(int m, float f){...}


    答案:D

  • 第5题:

    下列程序的输出结果是______。 include using namespace std; class base { public: in

    下列程序的输出结果是______。

    include<iostream>

    using namespace std;

    class base

    {

    public:

    int n;

    base(int x){n=x;}

    virtual void set(int m){n=m;cout<<n<<'';}

    };

    class deriveA:public base

    {

    public:

    deriveA(int x):base(x){}

    void set(int m){n+=m;cout<<n<<'';}

    };

    class deriveB:public base

    {

    public:

    deriveB(int x):base(x){}

    void set(int m){n+=m;cout<<n<<'';}

    };

    int main( )

    {

    deriveA d1(1);

    deriveB.d2(3);

    base*pbase;

    pbase=&d1;

    pbase->set(1);

    pbase=&d2;

    pbase->set(2);

    return 0;

    }


    正确答案:25
    25 解析:本题考核虚函数的定义和调用。在C++中,一个基类指针(或引用)可以用来指向它的派生类对象,而且通过这样的指针(或引用)调用虚函数时,被调用的是该指针(或引用)实际所指向的对象类的那个重定义版本。题中基类成员函数set( )被定义成虚函数,而且其派生类 deriveA和deriveB都有函数set( )的重定义版本,所以通过指针pbase的两次调用分别调用的是派生类deriveA和deriveB中定义的版本,即输出25。

  • 第6题:

    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

  • 第7题:

    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

  • 第8题:

    Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()

    • A、 ConstOver() {}
    • B、 protected int ConstOver(){}
    • C、 private ConstOver(int z, int y, byte x ) {}
    • D、 public Object ConstOver(Int x, int y, int z) {}
    • E、 pubic void ConstOver (byte x, byte y, byte z) {}

    正确答案:A,C

  • 第9题:

    public class MethodOver  {  public void setVar (int a, int b, float c)  {  }  }   Which two overload the setVar method?()  

    • A、 Private void setVar (int a, float c, int b)  { }
    • B、 Protected void setVar (int a, int b, float c) { }
    • C、 Public int setVar (int a, float c, int b) (return a;)
    • D、 Public int setVar (int a, int b, float c) (return a;)
    • E、 Protected float setVar (int a, int b, float c) (return c;)

    正确答案:A,C

  • 第10题:

    多选题
    下列哪些是方法public  int  add (int a)的重载方法?()
    A

    public  int  add (long a);

    B

    public  void  add (int a);

    C

    public void add (long a);

    D

    public  int  add (float a);


    正确答案: B,C
    解析: 暂无解析

  • 第11题:

    多选题
    给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A }
    A

    public int cal(int x,int y,float z){return 0;}

    B

    public int cal(int x,int y,int z){return 0;}

    C

    public void cal(int x,int z){}

    D

    public viod cal(int z,int y,int x){}


    正确答案: B,D
    解析: 暂无解析

  • 第12题:

    多选题
    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
    解析: 暂无解析

  • 第13题:

    下列程序段中,正确的是______。 ①class MvClass { int var = 100; static int getVar() { return var; } } ②public class MyClass { final int date; void MyClass (int d) { date = d; } } ③public class MyMain { public static void main(String args[]) { System.out.println(Myclass1.date); } } class MyClass1 { int data = 10; } ④class IamAbstract { final int f; double d; abstrct void method(); }

    A.②④

    B.①③

    C.②

    D.以上都不对


    正确答案:D

  • 第14题:

    若有以下程序:include using namespace std;class myClass{private: int var;public:

    若有以下程序: #include <iostream> using namespace std; class myClass { private: int var; public: myClass(int i) { var=i; } void add() { s+=var; } static int s; void display() { cout<<s<<end1; } }; int myClass::s=0; int main ( ) { myClass a(1),b(2),c(3); a.add(); b.add(); c.dislay(); return O; } 程序执行后的输出结果是( )。

    A.1

    B.4

    C.3

    D.7


    正确答案:C
    解析:本题考核静态数据成员的应用。解本题的关键是知道静态数据成员类中所有对象共享的成员。每个对象对静态数据成员的操作具有叠加效果。本题在类myClass中定义了一个静态数据成员s,其初始值为0。定义了3个对象a、b和c,并分别初始化各自的私有成员n为1、2和3。执行“a.add();”语句后,静态数据成员s=1。再执行语句“b.add();”后,s的值变为3。最后执行输出语句“c.display();”,即输出s的值7。

  • 第15题:

    下列重载函数中,正确的是( )。

    A.void fun(int a,float b);void fun(int C,float d)

    B.void fun(int a,float b);void fun(float a,int b)

    C.float fun(int a,float b);int fun(int b,float a)

    D.int fun(int a,int b);float fun(int a,int b)


    正确答案:B

  • 第16题:

    指出下列哪个方法与方法public void add(int a){}为错误的重载方法()

    A、public int add(int a)

    B、public void add(long a)

    C、public int add(long a)

    D、public void add(float a)


    答案:A

  • 第17题:

    下列哪些是方法public  int  add (int a)的重载方法?() 

    • A、  public  int  add (long a);
    • B、  public  void  add (int a);
    • C、  public void add (long a);
    • D、  public  int  add (float a);

    正确答案:A,C,D

  • 第18题:

    Which line contains a constructor in this class definition?()   public class Counter { // (1)   int current, step;   public Counter(int startValue, int stepValue) { // (2)   set(startValue);   setStepValue(stepValue);  }   public int get() { return current; } // (3)   public void set(int value) { current = value; } // (4)   public void setStepValue(int stepValue) { step = stepValue; } // (5)  }  

    • A、Code marked with (1) is a constructor
    • B、Code marked with (2) is a constructor
    • C、Code marked with (3) is a constructor
    • D、Code marked with (4) is a constructor
    • E、Code marked with (5) is a Constructor

    正确答案:B

  • 第19题:

    Which method must be defined by a class implementing the java.lang.Runnable interface? () 

    • A、 void run()
    • B、 public void run()
    • C、 public void start()
    • D、 void run(int priority)
    • E、 public void run(int priority)
    • F、 public void start(int priority)

    正确答案:B

  • 第20题:

    public class MethodOver {   private int x, y;   private float z;   public void setVar(int a, int b, float c){   x = a;   y = b;   z = c;   }   }   Which two overload the setVar method?()

    • A、 void setVar (int a, int b, float c){  x = a;  y = b;  z = c;  }
    • B、 public void setVar(int a, float c, int b) {  setVar(a, b, c);  }
    • C、 public void setVar(int a, float c, int b) {  this(a, b, c);  }
    • D、 public void setVar(int a, float b){  x = a;  z = b;  }
    • E、 public void setVar(int ax, int by, float cz) {  x = ax;  y = by;  z = cz;  }

    正确答案:B,D

  • 第21题:

    多选题
    public class MethodOver  {  public void setVar (int a, int b, float c)  {  }  }   Which two overload the setVar method?()
    A

    Private void setVar (int a, float c, int b)  { }

    B

    Protected void setVar (int a, int b, float c) { }

    C

    Public int setVar (int a, float c, int b) (return a;)

    D

    Public int setVar (int a, int b, float c) (return a;)

    E

    Protected float setVar (int a, int b, float c) (return c;)


    正确答案: D,C
    解析: 暂无解析

  • 第22题:

    多选题
    Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()
    A

    ConstOver() {}

    B

    protected int ConstOver(){}

    C

    private ConstOver(int z, int y, byte x ) {}

    D

    public Object ConstOver(Int x, int y, int z) {}

    E

    pubic void ConstOver (byte x, byte y, byte z) {}


    正确答案: B,D
    解析: 暂无解析

  • 第23题:

    多选题
    public class MethodOver {  private int x, y;  private float z;  public void setVar(int a, int b, float c){  x = a;  y = b;  z = c;  }  }   Which two overload the setVar method?()
    A

    void setVar (int a, int b, float c){ x = a; y = b; z = c; }

    B

    public void setVar(int a, float c, int b) { setVar(a, b, c); }

    C

    public void setVar(int a, float c, int b) { this(a, b, c); }

    D

    public void setVar(int a, float b){ x = a; z = b; }

    E

    public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }


    正确答案: A,B
    解析: 暂无解析

  • 第24题:

    ( 难度:中等)下面哪个函数是 public void example(){...} 的重载函数?
    A.private void example( int m){...}
    B.public int example(){...}
    C.public void example2(){...}
    D.public int example ( int m, float f){...}
    E.public int example ( int m, float f, int cc){...}

    答案:DE