首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

写出以下程序的运行结果

class A

{

int a;

A(int b)

{a=b;}

void show()

{System.out.println(“a=”+a);}

}

public class Class1

{

public static void main (String args[])

{

A bj=new A(12345);

boolean b=false;

char ch=97;

obj.show();

System.out.println(“b=”+b+”/tch=”+ch);

}

}

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“写出以下程序的运行结果”相关的问题
第1题
编译运行以下程序后,关于输出结果的说明正确的是()。 public class Conditional{ public static

编译运行以下程序后,关于输出结果的说明正确的是()。 public class Conditional{ public static void main (String args[]){ int x=2: System.out.println("value is”+ ((x<1)?2:2)); } }

A.输出结果为:valueis22.2

B.输出结果为:value is 2

C.输出结果为:value is 2.0

D.编译错误

点击查看答案
第2题
以下程序的运行结果为:public class Test{public static void main(String argv[ ]){System.out.println("x="+ 5、;}}

A. 5

B. x=5

C. "x="+5

D. "x="5

点击查看答案
第3题
以下程序的运行结果为:public class Test{public static void main(String argv[ ]){System.out.println("good"+"morning");}}

A. goodmorning

B. "good"+"morning"

C. good morning

D. good+morning

点击查看答案
第4题
以下程序的运行结果为class Prob10 {static boolean b1;public static void main(String [] args

以下程序的运行结果为

class Prob10 {

static boolean b1;

public static void main(String [] args) {

int i1 = 11;

double f1=1.3;

do {

b1 = (f1 >4、&& (i1--< 10);

f1 += 1.0;

} while (!b 1、;

System.out.println(b1 + "," + i1 + "," + f 1、;

}

}

A. false,9,4.3

B. true,11,1.3

C. false,8,1.3

D. true,8,7.3

点击查看答案
第5题
以下程序的运行结果为?class xyz {public static void main(String args[]) {int i,j,k;for (i

以下程序的运行结果为?

class xyz {

public static void main(String args[]) {

int i,j,k;

for (i = 0; i< 3; i++) {

for(j=1; j< 4; j++) {

for(k=2; k<5; k++) {

if((i == j) && (j==k))

System.out.println(i);

}

}

}

}

}

A. 0

B. 1

C. 2

D. 3

E. 4

点击查看答案
第6题
以下程序的运行结果为?class ValHold{public int i = 10;}public class ObParm{public static

以下程序的运行结果为?

class ValHold{

public int i = 10;

}

public class ObParm{

public static void main(String argv[]){

ObParm o = new ObParm();

o.amethod();

}

public void amethod(){

int i = 99;

ValHold v = new ValHold();

v.i=30;

another(v,i);

System.out.print(v.i );

}

public void another(ValHold v, int i){

i=0;

v.i = 20;

ValHold vh = new ValHold();

v = vh;

System.out.print(v.i);

System.out.print(i);

}

}

A.10030

B. 20030

C. 209930

D. 10020

点击查看答案
第7题
以下程序的编译运行结果为:1: public class Q102: {3: public static void main(String[] args)4

以下程序的编译运行结果为:

1: public class Q10

2: {

3: public static void main(String[] args)

4: {

5: int i = 10;

6: int j = 10;

7: boolean b = false;

8:

9: if(b = i == j)

10: System.out.println("True");

11: else

12: System.out.println("False");

13: }

14: }

A. 第9行出现编译错误;

B. 第9行出现运行错误;

C. 输出 True

D. 输出 False

点击查看答案
第8题
以下程序的运行结果为?class test {public static void main(String args[]) {int i,j=0;for(i

以下程序的运行结果为?

class test {

public static void main(String args[]) {

int i,j=0;

for(i=10;i<0;i--) { j++; }

switch(j) {

case (0) : j=j+1;

case (1、 : j=j+2; break;

case (2、: j=j+3; break;

case (10) : j=j+10; break;

default : break;

}

System.out.println(j);

}

}

A. 0

B. 1

C. 2

D. 3

E. 10

点击查看答案
第9题
以下程序的运行结果为:public class A {static int k=3;public static void main(String[] args) {int k=4;A x1=new A();x1.k++;A x2=new A();x2.k++;k++;System.out.println(x1.k);}}

A. 3

B. 4

C.5

D.6

E.7

点击查看答案
第10题
以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}}

A. 输出结果为 0

B. 运行出错

C. 输出结果为 null

D. 编译错误

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改