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

给出如下代码:class Test{ private int m; public static void fun() { // some code... } } 如何使成员变量m 在方法fun()中直接访问? ()

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

提问人:网友gdlym3339862 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有3位网友选择 C,占比37.5%
  • · 有3位网友选择 B,占比37.5%
  • · 有2位网友选择 D,占比25%
匿名网友 选择了B
[164.***.***.173] 1天前
匿名网友 选择了B
[235.***.***.84] 1天前
匿名网友 选择了B
[83.***.***.166] 1天前
匿名网友 选择了D
[14.***.***.109] 1天前
匿名网友 选择了C
[67.***.***.142] 1天前
匿名网友 选择了C
[83.***.***.128] 1天前
匿名网友 选择了C
[164.***.***.117] 1天前
匿名网友 选择了D
[66.***.***.65] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“给出如下代码:class Test{ private int…”相关的问题
第1题
给出如下代码:classtest{privateintm;publicstaticvoidfun(){//somecode...}}如何使成员变量m被函数fun()直接访问()。

A、将privateintm改为protectedintm

B、将privateintm改为publicintm

C、将privateintm改为staticintm

D、将privateintm改为intm

点击查看答案
第2题
关于以下程序段的说明正确的是 ( )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、编译不能通过

点击查看答案
第3题
Given the following code:

public class Test {

void printValue(int m) {

do { System.out.println("The value is"+m);

}

while(--m >10 )

}

public static void main(String arg[]) {

int i=10;

Test t= new Test ();

t.printValue(i) ;

}

}

Which will be output?

A.The value is 8           B.The value is 9

C.The value is 10          D.The value is 11

点击查看答案
第4题
Given the following code:

1)class Person {

2) public void printValue(int i, int j) {/*…*/ }

3) public void printValue(int i) {/*…*/

4) }

5) public class Teacher extends Person {

6) public void printValue() {/*…*/ }

7) public void printValue(int i) {/*…*/}

8) public static void main(String args[]) {

9) Person t = new Teacher();

10) t.printValue(10) ;

11)}

12)}

Which method will the statement on line 10 call?

A.on line 2            B.on line 3

C.on line 6            D.on line 7

点击查看答案
第5题
运行以下代码: class Two{ byte x; } class PassO{ public static void main(String[] args){ PassO p = new PassO( ); p.start( ); } void start( ){ Two t = new Two( ); System.out.print(t.x + “ ”); Two t2 = fix(t); System.out.println(t.x + ” ” + t2.x); } Two fix(Two tt){ tt.x = 42; return tt; } } 运行结果是( )。

A、null null 42

B、0 42 42

C、0 0 0

D、编译出错

点击查看答案
第6题
【填空题】A 5×6 inch photograph when scanned at 200dpi will result in an image which is ________ pixels.
点击查看答案
第7题
程序中头文件myfile.h的内容是: define N 5 define M1 N*3 程序文件code.C内容如下: 1nClUde include”myfile.h” define M2 N*2 void main() { int i; i=M1+M2; printf("%d\n",i); } 程序编译后运行的输出结果是()。

A.1 0

B.20

C.25

D.30

点击查看答案
第8题
下列程序执行之后,将会输出( )。注意:程序中的符号为英文状态下的符号(如逗号和分号)。public class Counter { int myCount =100; static int ourCount =500; void increment() { myCount++; ourCount++; } public static void main(String[] args) { Counter counter1 = new Counter(); Counter counter2 = new Counter(); counter1.increment(); counter1.increment(); System.out.print(counter1.myCount+","+counter1.ourCount+","); counter2.increment(); System.out.print(counter2.myCount+","+counter2.ourCount); } }
点击查看答案
第9题
指出下列程序运行的结果 ( )。注意:输出结果中符号为英文状态下的符号。public class DayDreaming { public static void main(String[] args) { double[ ] salary = {6000}; int[ ] nCarsHouses = {0,0}; DayDreaming(salary, nCarsHouses); System.out.println(salary[0]+ " " + nCarsHouses[0] + " " + nCarsHouses[1]); } static void DayDreaming(double[] salary, int[] nCarsHouses) { salary[0] = salary[0] * 3; nCarsHouses[0] += 2; nCarsHouses[1] ++; } }
点击查看答案
第10题
请写出下述程序的输出结果( )。class Counter { int i = 0; } public class Reference { public void plus(int i) { i++; } public void plus(Counter c) { c.i++; } public void create(Counter c) { c = new Counter(); c.i++; } public static void main(String[] args) { int i = 0; Reference r = new Reference(); Counter c1 = new Counter(), c2 = new Counter(); r.plus(i); System.out.print(i); r.plus(c1); System.out.print(c1.i); r.create(c2); System.out.print(c2.i); } }
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

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

简答题官方微信公众号

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

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

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