题目内容 (请给出正确答案)
[单选题]

有如下类定义: public?class?ClassAndVariables{ ????public?static?int?x?=?8;? ????public?int?y?=?9;? } 执行如下代码: ClassAndVariables?a?=?new?ClassAndVariables(); ClassAndVariables?b?=?new?ClassAndVariables(); a.y?=?5; b.y?=?6; a.x?=?1; b.x?=?2; 则a.y,?b.y,?a.x,?b.x的值分别为:

A.5, 6, 1, 2

B.6, 6, 1, 2

C.5, 6, 2, 2

D.6, 6, 2, 2

提问人:网友bnuepitc 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有4位网友选择 B,占比44.44%
  • · 有3位网友选择 A,占比33.33%
  • · 有2位网友选择 C,占比22.22%
匿名网友 选择了B
[63.***.***.119] 1天前
匿名网友 选择了A
[254.***.***.79] 1天前
匿名网友 选择了C
[20.***.***.167] 1天前
匿名网友 选择了B
[66.***.***.17] 1天前
匿名网友 选择了A
[180.***.***.166] 1天前
匿名网友 选择了B
[78.***.***.143] 1天前
匿名网友 选择了C
[247.***.***.212] 1天前
匿名网友 选择了A
[18.***.***.28] 1天前
匿名网友 选择了B
[224.***.***.119] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“有如下类定义: public class ClassAndV…”相关的问题
第1题
现有分数类: class Fraction { public: Fraction(int x, int y) {fenzi = x;fenmu = y;} private: int fenzi; int fenmu; };
点击查看答案
第2题
已知: package p; class C { public int x; } 那么,在哪种情况下可以访问 x

A、任意类

B、只有类 C

C、只有类 C 的子类

D、包 p 中的类

点击查看答案
第3题
Number类定义如下: public class Number { public int x; } swap方法定义如下: public static void swap(Number number1, Number number2) { int temp = number1.x; number1.x = number2.x; number2.x = temp; } 运行如下代码: Number number1 = new Number(); Number number2 = new Number(); Number number3 = new Number(); number1.x = 1; number2.x = 2; number3.x = 3; swap(number1, number2); swap(number2, number3); 则number1.x, number2.x, number3.x的值分别为:

A、1, 2, 3

B、2, 3, 1

C、3, 2, 1

D、1, 3, 2

点击查看答案
第4题
有以下定义: class point{ int m,n; public: void set(int x,int y){this->m=x;this->n=y;} }; Point *pointer; 则以下哪种使用是正确的:

A、pointer->m=3;

B、cout<<pointer-> n;

C、p->set(1,2)

D、p.set(1,2)

点击查看答案
第5题
类运算符重载实例如下: class CMyPoint { int x, y; public: CMyPoint(int i, int j){ x=i; y=j; } CMyPoint operator+(CMyPoint &p) //二元运算符 {return CMyPoint(x+p.x, y+p.y);} CMyPoint operator–(CMyPoint &p) //二元运算符 {return CMyPoint(x-p.x, y–p.y);} }; p1,p2为该类的实例,则如下调用方法中,错误的是( )

A、CMyPoint p3=p1+p2;

B、operator +(p1,p2);

C、p1=p1.operator +(p2);

D、p1=p1 +(p2);

点击查看答案
第6题
指出下列程序中的错误,并简洁说明错误原因 class AC { public: AC(int a) { x = a; } private: int x; }; class CD:public AC { public: CD(){ } };
点击查看答案
第7题
类型转换函数实例: class CMyPoint { int x, y; public: CMyPoint(int i, int j) { x = i; y = j; } operator double(); //转换为到原点的距离 }; 请完成CMyPoint的类型转换函数,使(double)p;能够返回p和原点的距离。
点击查看答案
第8题
已定义类A:class A { public: int x; static int y; }; int A::y = 0; 下列语句中错误的是( )。

A、A a; a.x = 1; a.y = 1;

B、A a; a.x = 1; A::y = 1;

C、A.x = 1; A.y = 1;

D、A::y = 1;

点击查看答案
第9题
已定义基类A和派生类B:class A { ptivate: int x; protected: int y; public: int z; void ShowA( ) { cout << x << y << z << endl; } }; class B : protected A // 保护继承 { private : int a; protected: int b; public: int c; void ShowB( ) { ShowA( ); cout << a << b << c << endl; } }; 再定义B的派生类C:class C : public B { public: int m; void fun( ) { x = 5; y = 5; z = 5; ShowA( ); } // 访问基类A的成员 }; 函数fun( )中错误的语句是( )。

A、x = 5;

B、y = 5;

C、z = 5;

D、ShowA( );

点击查看答案
第10题
有如下TestA类的定义: public class TestA { static int a=10; } 用该类创建2个对象:testA1和testA2,现将类变量(静态变量)a的数值变为100,则正确的方式是:( )。

A、TestA.a=100;

B、testA1.a=100;

C、testA2.a=100;

D、其余选项都不对

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信