重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
找答案首页 > 全部分类 > 大学本科
搜题
网友您好, 请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
[单选题]

已定义类A: class A { ptivate: int x; protected: int y; public: int z; void ShowA()

A.cout << x;

B.cout << y;

C.cout << z;

D.cout << a;

答案
A、cout << x;
更多“已定义类A: class A { ptivate: int x; protected: int y; public: int z; void ShowA()”相关的问题

第1题

设有如下类

class Loop{

public static void main(String[] agrs) {

int x=0;int y=0;

outer:

for(x=0;x<100;x++){

middle:

for(y=0;y<100;y++){

System.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

点击查看答案

第2题

publicclassAssertStuff{publicstaticvoidmain(String[]args){intx=5;inty=7;assert(x>y):stuff”;System.out.println(”passed”);}}Andthesecommandlineinvocations:javaAssertStuffjava-eaAssertStuffWhatistheresult?()

A.passedstuff

B.stuffpassed

C.passed AnAssertionErroristhrownwiththeword“stuff”addedtothestacktrace.

D.passed AnAssertionErroristhrownwithouttheword“stuff”addedtothestacktrace.

E.passed AnAssertionExceptionisthrownwiththeword“stuff”addedtothestacktrace.

F.passed AnAssertionExceptionisthrownwithouttheword“stuff”addedtothestacktrace.

点击查看答案

第3题

现有importjava.io.PrintWriter;classDoFormat{publicstaticvoidmain(String[]args){intx=42;inty=12345;floatZ-7;System.out.format("一%4d-",X);System.out.format("-%4d-",y);System.out.format("-%4.ld-",z);}}结果为:()

A.编译失败

B.-42--1234--7.0-

C.-42--1234--7.0-

D.-42--12345--7.0-

E.运行时异常被抛出

点击查看答案

第4题

有以下程序: int fl(int x,int Y) { return x>y?x:y; } int f2(int x,int y) { return x>y?Y:x; } void main() { int a=4,b=3,c=5,d=2,e,f,g; e=f2(fl(a,b),fl(c,d)); f=fl(f2(a,b),f2(c,d)); g=a+b+c+d—e—f; printf(“%d,%d,%d\n”,e,f,g); } 程序运行后的输出结果是( )。

A.4,3,7

B.3,4,7

C.5,2,7

D.2,5,7

点击查看答案

第5题

23.intz=5;24.25.publicvoidstuff1(intx){26.assert(x>0);27.switch(x){28.case2:x=3;29.default:assertfalse;}}30.31.privatevoidstuff2(inty){assert(y<0);}32.33.privatevoidstuff3(){assert(stuff4O);}34.35.privatebooleanstuff4(){z=6;returnfalse;}Whichistrue?()

A.Alloftheassertstatementsareusedappropriately.

B.Onlytheassertstatementonline31isusedappropriately.

C.Theassertstatementsonlines29and31areusedappropriately.

D.Theassertstatementsonlines26and29areusedappropriately.

E.Theassertstatementsonlines29and33areusedappropriately.

F.Theassertstatementsonlines29,31,and33areusedappropriately.

G.Theassertstatementsonlines26,29,and31areusedappropriately.

点击查看答案

第6题

publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){for(inti=0;i<5;i++){newThread(){publicvoidrun(){foo();System.out.print(x+,);}}.start();}}}Whichtwochanges,takentogether,wouldguaranteetheoutput:1,2,3,4,5,?()

A.Movetheline12printstatementintothefoo()method.

B.Changeline7topublicsynchronizedvoidgo(){.

C.Changethevariabledeclarationonline3toprivatevolatileintx;.

D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.

E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}.

点击查看答案

第7题

使用VC6打开考生文件夹下的工程test12_3,此工程包含一个test12_3.cpp,其中定义了类Base和类A,类A公有继承 Base,但这两个类的定义都并不完整。请按要求完成下列操作,将程序补充完整。

(1)定义枚举类型变量en,它包含两个枚举符front和back,请在注释“//**1**”之后添加适当的语句。

(2)在类Base中添加常成员虚函数void E()的定义,该函数输出“In Base E!”,请在注释“//**2**”之后添加适当的语句。

(3)在类A中添加常成员虚函数void E()的定义,该函数先调用基类中的虚函数 E()再输出“In AE!”,请在注释“//** 3**”之后添加适当的语句。

(4)完成类A构造函数的定义,请使用参数列表的形式初始化类A的成员,并输出“A constructor.”,请在注释“//** 4**”之后添加适当的语句。

输出结果如下:

Base constructor.

A constructor.

In BaseE!

In AE!

In BaseP!

In A!

1

A destructor.

Base destructor.

注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。

源程序文件test12_3.cpp清单如下:

include<iostream .h>

// ** 1 **

class Base

{

protected:

int b1;

int b2;

public:

Base();

~Base();

int Getb1()const { return b1; }

void Setb1(int x){ b1 = x; }

int Getb2()const { return b2; }

void Setb2(int y) { b2 = y; }

void Print()const {cout<<"In Base P!"<<end1;}

// ** 2 **

};

Base::Base():b1(1),b2(5)

{

cout<<"Base constructor."<<endl;

}

Base::~Base()

{

cout<<"Base destructor."<<endl;

}

class A:public Base

{

protected:

en enA;

public:

A();

~A();

en GetColor()const { return enA; }

void SetColor(en color){ enA = color; }

void InA(){cout<<"In A!"<<endl;}

// ** 3 **

{

Base::E();

cout<<"In AE!"<<endl;

}

};

// ** 4 **

{

cout<<"A constructor."<<endl;

}

A::~A()

{

cout<<"A destructor."<<endl;

}

void main()

{

A a1;

a1.E();

cout<<endl;

a1.Print();

a1.InA();

cout<<a1.Getbl()<<endl;

}

点击查看答案

第8题

以下程序执行后输出结果是()

#include

int MaxValue(int x, int y)

{

return x>y? x:y;

}

int MinValue(int x,int y)

{

return x>y? y:x;

}

int main()

{

int a=4,b=3,c=5,d,e,f;

d=MaxValue(a,b);

d=MaxValue(d,c);

e=MinValue(a,b);

e=MinValue(e,c);

f=a+b+c-d-e;

printf("%d,%d,%d\n",d,f,e);

return 0;

}

A.5,4,3

B.3,5,4

C.3,4,5

D.5,3,4

点击查看答案

第9题

现有:publicclassTester{publicstaticvoidmain(String[]args){intx-5;Integerxl=x;Integerx2=x;intx3=newInteger(5);system..ut.print(x1.equals(x));system..ut.print(xl==x);system..ut.print(x2.equals(xl));system..ut.print(x2==xl);system..ut.print(x2==x3);system..ut.print(x2.equals(x3));}}结果为:()

A.编译失败

B.falsefalsetruetruetruetrue

C.truetruetruetruetruetrue

D.falsefalsetruetruetruefalse

E.truefalsetruefalsefalsetrue

F.运行时异常被抛出

点击查看答案

第10题

classTestReference{publicstaticvoidmain(String[]args){intx=2;TestReferencetr=newTestReference();System.out.print(x);tr.change(x);System.out.print(x);}publicvoidchange(intnum){num=num+1;}}程序运行后的输出是哪项()?

A.23

B.21

C.22

D.编译错误

点击查看答案
下载上学吧APP
客服
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
选择优惠券
优惠券
请选择
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)
订单号:
遇到问题请联系在线客服
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

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

- 微信扫码关注上学吧 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注上学吧 -
请用微信扫码测试
选择优惠券
确认选择
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,如果您知道正确答案,欢迎您来纠错

上学吧找答案