搜题
网友您好,请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
提问人:网友jellyku 发布时间:2022-01-07
[主观题]

关于以下程序代码的说明正确的是()(1)class HasStatic{(2)private static int x=100;(3)public s

关于以下程序代码的说明正确的是 ()(1)class HasStatic{(2)private static int x=100;(3)public static void main(String args[]){(4)HasStatic hs1=new HasStatic();(5)hs1.x++;(6)HasStatic hs2=new HasStatic();(7)hs2.x++;(8)hs1=new HasStatic();(9)hs1.x++;(10)System.out.println("x="+x);(11)}(12)}

A.(5)行不能通过编译,因为引用了私有静态变量

B.(10)行不能通过编译,因为x是私有静态变量

C.程序通过编译,输出结果为:x=103

D.程序通过编译,输出结果为:x=100

简答题官方参考答案 (由简答题聘请的专业题库老师提供的解答)
查看官方参考答案
更多“关于以下程序代码的说明正确的是()(1)class HasStatic{(2)private static int x=100;(3)public s”相关的问题
第1题
以下程序运行结果是 public class HasStatic { private static int x=100; public static void main(String args[ ]){ HasStatic hs1=new HasStatic( ); hs1.x++; HasStatic hs2=new HasStatic( ); hs2.x++; hs1=new HasStatic( ); hs1.x++; HasStatic.x--; System.out.println("x="+x); } }

A、x=103

B、x=102

C、x=101

D、编译错误

点击查看答案
第2题

下列程序运行结果是 。 class test{ long x; static int num; public: test (long m=0) {x=m;} test operator++(); test operator++(int); void Show() { cout<<"the num is:> <<",x="<> < <endl; } }; test test::operator++() { ++x; num is: the answer"> 参考答案: <span style="color:rgb(255, 0, 0)">The num is: 1,x=1 The num is: 2,x=3 The num is: 3,x=3 The num is: 3,x=1</span>

2、下列程序运行结果是 。 #include <iostream.h> class A { long x; public: A(long m) {x=m;} void Show() { cout<<"count="<> <<",x="<> < <endl; } a& operator++(); operator++(int); static int count; }; a::operator++() { ++x; ,x="&lt;&lt;x&lt;&lt;endl; A temp(*this); x++; return temp; } int A::count=1; void main() { A a(1); a.operator++(1); a.operator++(); a.Show(); }&lt;br/&gt;&lt;p class=" count="&lt;&lt;count++&lt;&lt;" answer"> 参考答案: <span style="color:rgb(255, 0, 0)">count=1,x=1 count=2,x=3 count=3,x=3</span>

3、下列程序运行结果是 。 class sample{ int x , y ; public : sample( ) { x=y=0 ; } sample( int i , int j) {x=i ; y=j ; } void copy( sample &obj) { *this=obj ; } sample operator--( ) { x-- ; y-- ; return *this; } void print( ){ cout << x << " " << y<< " " ; } } ; void main( ) { sample c1(1 , 2) , c2 ; --c1; c1.print( ) ; c2.copy(c1) ; --c2; c2.print( ) ; }

点击查看答案
第3题
以下程序段输出的结果是( )。 int i=1; int b,c; int a[]=new int[3]; b=a[i]; c=b+i; System.out.println(c);

A、0

B、1

C、2

D、3

点击查看答案
第4题
下面程序代码输出结果是 public class Test{ int x,y; Test(int x,int y ){ this.x = x; this.y = y; } public static void main(String args[]){ Test p1,p2; p1 = new Test(3,3); p2 = new Test(4,4); System.out.println(p1.x+p2.x); } }

A、6

B、3 4

C、8

D、7

点击查看答案
第5题
请写出下题的运行结果: #include<iostream> using namespace std; class B { public: void print(){cout<<"b";} }; d:public b { public: void main() d *pd="new" d(); *pb="pd;" pb->print(); pd->print(); delete pd; }
点击查看答案
第6题
已定义类A: class A { private int x = 1; protected int y = 2; public int z = 3; public int sumA( ) { return( x +y +z ); } } 再通过继承与扩展定义子类B: class B extends A { private int b = 4; public int sumB( ) { int s = 0; s += x; s += y; s += z; s += b; return s; } } 方法成员sumB( )中错误的语句是( )。

A、s += x;

B、s += y;

C、s += z;

D、s += b;

点击查看答案
第7题
(2)请说出A类中 System.out.println 的输出结果。 class B { int x = 100,y = 200; public void setX(int x) { x = x; } public void setY(int y) { this.y = y; } public int getXYSum() { return x+y; } } public class A { public static void main(String args[]) { B b = new B(); b.setX(-100); b.setY(-200); System.out.println("sum="+b.getXYSum()); } }
点击查看答案
第8题
下列代码的下画线处应填入的方法名是( )。 import java.awt.*; import java.applet.*; public class Hello extends Applet{ public void (Graphics g){ 9.drawstring("How are you!",l0,10); } }

A.repaint

B.println

C.paint

D.show

点击查看答案
第9题
在Java中,用package语句说明一个包时,该包的层次结构必须是()。A.与文件的结构相同B.与文件目录的
在Java中,用package语句说明一个包时,该包的层次结构必须是()。

A.与文件的结构相同

B.与文件目录的层次相同

C.与文件类型相同

D.与文件大小相同

点击查看答案
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

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

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

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

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

请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

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

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

- 微信扫码关注简答题 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注简答题 -
请用微信扫码测试
欢迎分享答案

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

简答题官方微信公众号

简答题
下载APP
关注公众号
TOP