设有如下类:class MyPoint {void myMethod() {int x, y;x = 5; y = 3;System.out.print( " ( " + x + ", " + y + " ) " );switchCoords( x, y );System.out.print( " ( " + x + ", " + y + " ) " );}void switchCoords( int x, int y ) {int temp;temp = x;x = y;y = temp;System.out.print( " ( " + x + ", " + y + " ) " );}}如果执行myMethod()方法,则输出结果为?A. (5, 3、(5, 3、(5, 3、B. (5, 3、(3, 5、(3, 5、C. (5, 3、(3, 5、(5, 3、

设有如下类:

class MyPoint {

void myMethod() {

int x, y;

x = 5; y = 3;

System.out.print( " ( " + x + ", " + y + " ) " );

switchCoords( x, y );

System.out.print( " ( " + x + ", " + y + " ) " );

}

void switchCoords( int x, int y ) {

int temp;

temp = x;

x = y;

y = temp;

System.out.print( " ( " + x + ", " + y + " ) " );

}

}

如果执行myMethod()方法,则输出结果为?

A. (5, 3、(5, 3、(5, 3、

B. (5, 3、(3, 5、(3, 5、

C. (5, 3、(3, 5、(5, 3、


相关考题:

有如下类定义:class Point{int x_, y_;public:Point():x_(0), y_(0){}Point(int x, int y = 0):x_(x),y_(y){}};若执行语句Point a(2), b[3] , *c[4];则 Point 类的构造函数被调用的次数是A . 2 次B . 3 次C . 4 次D . 5 次

使用VC6打开考生文件夹下的工程test23_3,此工程包含一个源程序文件test23_3.cpp,其中定义了类X和它的友元类Y,但它们的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)将类X的静态数据成员y初始化为1。请在注释“//**1**”之后添加适当的语句。(2)完成类Y的构造函数Y(int i,int j)的定义,将参数i赋值给类Y的数据成员,X的对象a中的数据成员x,并且把参数j赋值给类X的数据成员y,请在注释“//**2**”之后添加适当的语句。(3)完成类Y的成员函数void Display()的定义,将Y的数据成员,X的对象a中的数据成员x和类X的数据成员y按照“x=_,y=_”的形式显示出来(“_”代表一个数字),请在注释“//**3**”之后添加适当的语句。输出结果如下:x=5,y=lx=6,y=9x=5,y=9注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test23_3.cpp清单如下:include<iostream.h>class X{friend class Y;public:void Set(int i) {x=i;}void Display(){cout<<"x="<<x<<",";cout<<"y="<<y<<endl;}private:int x;static int y;};class Y{public:Y(int i, int j)void Display();private:X a;};//**1**Y::Y(int i, int j){//**2**}void Y::Display(){//**3**}void main ( ){X b;b.Set(5);b.Display();Y c(6,9);c.Display();b.Display();}

在下面的类定义中,this指针的用途是______。 include class Sample { int x,y; publi 在下面的类定义中,this指针的用途是______。include<iostream.h>class Sample{int x,y;public:Sample(int i,int j){x=i;y=j;}void assign(Sample sa);};void Sample::assign(Sample p){if(this!=p){x=p.x;y=p.y;}}

以下程序的执行结果是______。 inelude class Sample { public: int x; int y; void 以下程序的执行结果是______。inelude<iostream.h>class Sample{public:int x;int y;void disp( ){cout<<"x="<<x<<",y="<<y<<endl;}};void main( ){int Sample::*pc;Sample s;pc=Sample::x;s.*pc=10;pc=Sample::y;s.*pc=20;s.disp( );}

完成下列类的构造函数,初始化语句为______。 include class Test { private: int x,y 完成下列类的构造函数,初始化语句为______。include<iostream.h>class Test{private:int x,y;public:void Test(int initx,int inity){______}void printx( ){cout<<x<<"-"<<y<<"="<<x-y;}};void main( ){Test x(300,200);x.printx( );}

如下的类定义,括号里应填( )。 class Myclass { public: MyClass(int a =0,int b =0) { X=a; Y=b; void Change ( ) const { X- =10; Y+ =10; public: ( )int X,Y;A.staticB.constC.mutableD.可以不添内容

下列程序的运行结果为 include class Location { protected: int X,Y; 下列程序的运行结果为 #include<iostream.h> class Location { protected: int X,Y; publiC: void SeX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy( ) {cout<<"X=" <<X<<" " <<"Y"=<< Y<< endl;} }; Class Rectangle :public Location{A.X=3 Y=5 X=3 Y=5 H=4 W=6B.X=3 Y=5 X=3 Y=5 H=3 W=6C.X=3 Y=5 X=3 Y=4 H=4 W=6D.X=3 Y=5 X=3 Y=3 H=4 W=6

有如下类的定义。应在空格处填入的语句是 ( )。 class MyClass { ______________ int x, y; public: MyClass(int a=0,int b=0) { x=a; y=b; } static void change{) { x-=10; y-=10; };A.staticB.constC.mutableD.不需要填入内容

有如下类的定义。那么空格处的语句是( )。 class MyClass { ____________int x,y; public: MyClass(int x1=0,int y1=0) { x=x1; y=y1; } static void change() { x+=10; y+=10; } };A.staticB.constC.privateD.不需要填入内容

设有如下程序: public class Sun { public static void main(String args[ ]) { int x,y; x=4; y=0; if(Math.pow(x,2)==16) y=x; if(Math.pow(x,2)15) y=1/x; if(Math.pow(x,2)>15) y=(int)Math.pow(x,2)+1; System.out.println(y); } } 程序的运行结果是( )。A.4B.17C.18D.0.25

设有如下程序: public class Sun { public static void main (String args[ ]) { int x,y; x= (int) Math.sqrt (2) /2+ (int) Math.random ()*2/2; y= (int) Math.sqrt (3) /3+ (int) Math.random ()*3/3; if (x>y) System.out.println ("x>y"); else if (x==y) System.out.println("x=y"); else System.out.println("x<y"); } } 程序运行的结果为( )。A.x>yB.x=yC.x<yD.以上都不对

下列程序执行之后,将输出 public class exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }A.28B.21C.14D.0

有如下类的定义,下划线处的语句是( )。class MyClass{_______________ int x, y;Public:MyClass (int a=0,int b=0){x=a;y=b;}static void change(){y-=10;y-=10;}};A.staticB.constC.mutableD.不需要填入内容

有如下类的定义。空格处的语句是class MyClass{ ______ int x, y;public: MyClass(int a=0, int b=0) { x=a; y=b; } static void change() { x-=10; y-=10; }};A.staticB.constC.privateD.不需要填入内容

下列程序的执行结果是( )。 #inClude<iostream.h) #include(stdlib.h) class TestClass { public: int x,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"x="<<x<<",y="<<y<<endl; } }; void main() {A.x=2,y=2B.x=2,y=3C.x=3,y=2D.x=3,y=3

有以下程序:include include using namespace std;class Y;class X{private 有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X { private: int x; char *strx; public: X(int a, char *str) { x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); } void show(Y ob) ; }; class Y { private: int y; char *stry; public: Y(int b,char *str) { y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); } friend void X: :show(Y ob) ; }; void X: :show(Y ob) { cout<<strx<<", "; cout<<ob, stry<<end1; } int main ( ) { X a(10,"X"); Y b (20, "Y"); a. show(B) ; return 0; } 执行后的输出结果是( )。A.X,YB.a,bC.X,XD.Y,Y

有如下类的定义,横线处的语句是( )。 class TestClass { ______ int x,y; public: TestClass(int a=0,int b=0) { X=a: y=b; } static void change() { y-=10; y-=10; } };A.publicB. privateC.staticD.protected

下面程序输出的结果是( )。 include using namespace std; class A{ 下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }A.34B.43C.33D.44

有如下程序:include using namespace std;class shapes{protected: int x, y;public: 有如下程序: #include <iostream> using namespace std; class shapes { protected: int x, y; public: void setvalue(int d, int w=O) { x=d; y=w; } virtual void disp()=O; }; class square : public shapes { public: void disp () { cout<<x*y<<end1; } }; int main ( ) { shapes *ptr; square s1; ptr=s1; ptr->setvalue (10, 5) ;ptr->disp(); return 0; } 执行上面的程序将输出( )。A.50B.5C.10D.15

下列程序的输出结果是includeclass Myclass{ public:My class(inti=0,int j=0) {x= 下列程序的输出结果是 #include<iostream.h> class Myclass{ public:My class(inti=0,int j=0) { x=i; y=j; } void show(){cout<<"x=" <<x<<" " <"y=" <<y<<endl;} void show()const{cout<<"x="<<""<<"y="<<y<<endl;} privated: int x; int y; }; void main() { Myclassmy1(3,4); const my2(7,8); myl.show();my2.show();}A.x=4,y=3;x=7,y=8B.x=3,y=4;X=7,y=8C.x=7,y=8;x=4,y=3D.x=8,y=7;x=7,y=8

设有如下类class Loop{public static void main(String[] agrs) {int x=0;int y=0;outer:for(x=0;xmiddle:for(y=0;ySystem.out.println("x="+x+"; y="+y);if(y==10){>}}}}}在>处插入什么代码可以结束外循环?A.continue middle;B.break outer;C.break middle;D.continue outer;E.none of these

给定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){}

The following methods are to be published as Web services to be invoked via SOAP messages and validated with a schema:  public void myMethod(int x, float y);  public void myMethod(int x);  public void someOtherMethod(int x, float y);  Which WSDL style should be used?()A、 RPC/literalB、 RPC/encodedC、 Document/encodedD、 Document/literalE、 Document/literal wrapped

Which two code fragments are most likely to cause a StackOverflowError?()A、int []x = {1,2,3,4,5};for(int y = 0; y  6; y++)    System.out.println(x[y]);B、static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }C、for(int y = 10; y  10; y++)doStuff(y);D、void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }E、for(int x = 0; x  1000000000; x++) doStuff(x);F、void counter(int i) { counter(++i); }

单选题The following methods are to be published as Web services to be invoked via SOAP messages and validated with a schema:  public void myMethod(int x, float y);  public void myMethod(int x);  public void someOtherMethod(int x, float y);  Which WSDL style should be used?()A RPC/literalB RPC/encodedC Document/encodedD Document/literalE Document/literal wrapped

多选题现有:  public  class  TestDemo{     private int X-2;      static int y=3;  public  void method(){      final int i=100;      int j  =10;     class Cinner {  public void mymethod(){      //Here     }     }     }     } 在Here处可以访问的变量是哪些?()AXByCjDi

多选题public class TestDemo{   private int x = 2;   static int y = 3;   public void method(){   final int i=100;   int j = 10;   class Cinner{   public void mymethod(){  //Here  }  }  }  }   在Here处可以访问的变量是哪些?()AxByCiDj