多选题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:}
第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
第2题:
有以下程序: #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
第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) { }
第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){...}
第5题:
下列程序的输出结果是______。
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;
}
第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 }
第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()?
第8题:
Given: 1. public class ConstOver { 2. public constOver(int x, int y, int z) { 3. } 4. } Which two overload the ConstOver Constructor?()
第9题:
public class MethodOver { public void setVar (int a, int b, float c) { } } Which two overload the setVar method?()
第10题:
public int add (long a);
public void add (int a);
public void add (long a);
public int add (float a);
第11题:
public int cal(int x,int y,float z){return 0;}
public int cal(int x,int y,int z){return 0;}
public void cal(int x,int z){}
public viod cal(int z,int y,int x){}
第12题:
private void set Var(int a, float c, int b) {}
protected void set Var(int a, int b, float c) {}
public int set Var(int a, float c, int b) {return a:}
public int set Var(int a, int b, float c) {return a:}
protected float set Var(int a, int b, float c) {return 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.以上都不对
第14题:
若有以下程序: #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
第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)
第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)
第17题:
下列哪些是方法public int add (int a)的重载方法?()
第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) }
第19题:
Which method must be defined by a class implementing the java.lang.Runnable interface? ()
第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?()
第21题:
Private void setVar (int a, float c, int b) { }
Protected void setVar (int a, int b, float c) { }
Public int setVar (int a, float c, int b) (return a;)
Public int setVar (int a, int b, float c) (return a;)
Protected float setVar (int a, int b, float c) (return c;)
第22题:
ConstOver() {}
protected int ConstOver(){}
private ConstOver(int z, int y, byte x ) {}
public Object ConstOver(Int x, int y, int z) {}
pubic void ConstOver (byte x, byte y, byte z) {}
第23题:
void setVar (int a, int b, float c){ x = a; y = b; z = c; }
public void setVar(int a, float c, int b) { setVar(a, b, c); }
public void setVar(int a, float c, int b) { this(a, b, c); }
public void setVar(int a, float b){ x = a; z = b; }
public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
第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