A: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; }}}
B: class MyClass{ int x; int y; public int this[int index] { set{ if (index==0) x=value; else y=value; }}}
C: class MyClass{ int x; int y; public int INDEX[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}
D: class MyClass{ int x; int y; public int this[int index] { get{ if (index==0) return x; else return y; } set{ if (index==0) x=value; else y=value; }}}
举一反三
- 在JSP页面中,下列( )代码能够正确的声明计算乘法的方法。 A: <;%!Public int mul(int x,int y){Return x*y ;}%>; B: <;%=public int mul(int x,int y){Return x*y ;}%>; C: <;%public int mul(int x,int y){%>;<;% returnx*y ;%>;<;%}%>; D: <;%Public int mul(int x,int y){Return x*y ;}%>;
- class A { public int f(int x,int y) { return x+y; } } class B extends A { public int f(byte x,int y) { return x*y; } } 子类B的对象只能调用子类中的f方法。( )
- 中国大学MOOC: 34. 下面是类MyClass的定义,对定义中各语句描述正确的是____。class MyClass{ public: void MyClass(int a){ X=a;} //① int f(int a,int b) //② { X=a; Y=b; } int f(int a,int b,int c=0) //③ { X=a; Y=b; } int f(int a,int b,int c=0) { X=a; Y=b; Z=c; } static void g(){ X=10;} //④ private: int X,Y,Z; };
- gcd (x,y)函数的功能是求x和y的最大公约数,在划线处填写正确的表达式: int gcd ( int x , int y) { if ( y == 0) return x; else return ____________________; }
- 假设输入5,10,以下程序运行的结果是( )。#include stdio.hint max(int a,int b){ if(a=b) return a; else return b;}int min(int a,int b){ if(a=b) return b; else return a;}void f(int a,int b,int(*p)(int,int)){ printf(%d\n,(*p)(a,b));}int main(){ int x,y; scanf(%d,%d,x,y); f(x,y,max); f(x,y,min); return 0;} A: 105 B: 55 C: 510 D: 1010
内容
- 0
有下列程序,程序运行后的输出结果是( )。 #include int fun (int x,int y); int main() { int a=4,b=5,c=6; printf("%d",fun(2*a,fun(b,c))); return 0; } int fun (int x,int y) { if (x!=y) return ((x+y)/2); else return (x); }
- 1
如果要实现计算x绝对值的功能,下面程序有错误的是? A: int fun(int x){ if(x<0) return -x;<br> return x; } B: int fun(int x){ if(x<0) return -x;<br> else return x; } C: int fun(int x){ if(x<0) return -x;<br> if(x>0) return x; } D: int fun(int x){ if(x<0) return -x;<br> else if(x==0) return x; else return x; }
- 2
下列类的定义中,正确的是() A: class a{int x=0;int y=1;}; B: class b{int x;int y=:1;}; C: class c{int x;int y;}; D: class d{int x=0,int y=1;};
- 3
,d); return 0; } int dif(int x,int y,int z) { int max(int x,int y,int z); int min(int x
- 4
下面正确的是() #include <stdio.h> int main() { int max(int x,int y); int a,b,c; scanf("%d,%d",&a,&b); c=max(a,b); printf("max=%d ",c); return 0; } int max(intx,inty); { int z; if(x>y)z=x; else z=y; return(z); }