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

【单选题】7.6若有下面的程序代码 class Test{ private int m; public static void fun(){ //some code } } 方法fun()如何来访问变量m()

A.将private int m 改成protected int m

B.将private int m 改成public int m

C.将private int m 改成static int m

D.将private int m 改成int m

提问人:网友audivolvo 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有5位网友选择 D,占比62.5%
  • · 有2位网友选择 C,占比25%
  • · 有1位网友选择 B,占比12.5%
匿名网友 选择了C
[237.***.***.2] 1天前
匿名网友 选择了D
[219.***.***.42] 1天前
匿名网友 选择了D
[199.***.***.85] 1天前
匿名网友 选择了C
[1.***.***.50] 1天前
匿名网友 选择了D
[153.***.***.35] 1天前
匿名网友 选择了D
[178.***.***.89] 1天前
匿名网友 选择了D
[201.***.***.60] 1天前
匿名网友 选择了B
[175.***.***.209] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“【单选题】7.6若有下面的程序代码 class Test{ …”相关的问题
第1题
给出如下代码:classtest{privateintm;publicstaticvoidfun(){//somecode...}}如何使成员变量m被函数fun()直接访问()。

A、将privateintm改为protectedintm

B、将privateintm改为publicintm

C、将privateintm改为staticintm

D、将privateintm改为intm

点击查看答案
第2题
给出如下代码: class Test{   … m;   public static void fun() {     // some code...   } } 如何声明成员变量m使其被函数fun()直接访问?

A、protected int m;

B、public int m;

C、static int m;

D、int m;

点击查看答案
第3题
关于以下程序段的说明正确的是 ( )public class Test { public static void main(String args[]) { try { int x[] = new int[-5]; System.out.println("此行将无法被执行!"); } catch (NegativeArraySizeException e) { System.out.println("exception: 数组下标不能为负数。"); } } }

A、编译通过,输出: 此行将无法被执行!

B、编译通过,输出: 此行将无法被执行! exception: 数组下标不能为负数。

C、编译通过,输出: exception: 数组下标不能为负数。

D、编译不能通过

点击查看答案
第4题

下列程序运行结果是 。 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( ) ; }

点击查看答案
第5题
现有分数类: class Fraction { public: Fraction(int x, int y) {fenzi = x;fenmu = y;} private: int fenzi; int fenmu; };
点击查看答案
第6题
若有如下程序: #include usingnamespacestd; classTestClassl { private: inta; public: TestClassl(inti) { a=i: } voiddisp() { cout$amp;A.10,10,10

B.10,12,14

C.8,10,12

D.8,12,10

点击查看答案
第7题
请补充代码,使得程序执行结果输出60。 class Test { public: static int x; Test(int i=0) { x=i+x; } int Getnum() { return Test::x+15; } }; (1); int main() { Test test(5); cout< <test.getnum(); return 0;>
点击查看答案
第8题
阅读下面的程序, 分析代码是否能够编译通过 class A { private int secret = 5; } public class Test1 { public static void main(); } }
A.可以编译通过

B.不能编译通过

点击查看答案
第9题
关于属性的使用正确的是

A、private int num; public string Num { get{return num;} set{num=value;} }

B、private int num; public int Num { get{return num;} set{num=value;} }

C、private int num; public int Num { get{num=value;} set{return num;} }

D、private int num; private int Num { get{return num;} set{num=value;} }

点击查看答案
第10题
【简答题】预测程序运行结果 class Student{ private String name; public static String classNo; public Student(){} public Student(String name, String classNo){ this.name=name; this.classNO=classNo;} public static void show(){ System.out.println(“name=”+name+”classNo=”+classNo);}} public class StudentDemo{ public static void main(String []args){ Student s1=new Student(“张”,”计1”); Student s2=new Student(“李”,”计2”); s1.show();
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

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

简答题官方微信公众号

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

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

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