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

编译和运行以下代码的结果为:public class MyMain{public static void main(String argv){System.out.println("Hello cruel world");}}

A.编译错误;

B.运行输出 "Hello cruel world";

C.编译无错,但运行时指示没有定义构造方法。

D.编译无错,但运行时指示没有正确定义main方法。

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“编译和运行以下代码的结果为:public class MyM…”相关的问题
第1题
编译和运行以下代码结果为:1. public class EqualsTest{2. public static void main(String ar

编译和运行以下代码结果为:

1. public class EqualsTest{

2. public static void main(String args[]){

3. byte A=(byte)4096;

4. if(A== 4096、System.out.println("Equal");

5. else System.out.println("Not Equal");

6. }

7. }

A.在第3行出现转换丢失精度的编译错误.

B.输出 "Not Equal".

C.输出 "Equal".

点击查看答案
第2题
以下代码的运行结果为:public class Calc {public static void main (String args []) {int to

以下代码的运行结果为:

public class Calc {

public static void main (String args []) {

int total = 0;

for (int i = 0, j = 10; total >30; ++i, --j) {

System.out.println(" i = " + i + " : j = " + j);

total += (i + j);

}

System.out.println("Total " + total);

}

}

A. 产生运行错误

B. 产生编译错误

C. 输出 "Total 0"

D. 产生如下输出:

i = 0 : j = 10

i = 1 : j = 9

i = 2 : j = 8

Total 30

点击查看答案
第3题
以下代码的输出结果?public class Test{public static void main(String argv[]){String x="hello";change(x);System.out.println(x);}static void change(String m){m=m+2;}}

A. hello

B. hello2

C. 编译报错

D. 运行报错,不能将串与整数相加

点击查看答案
第4题
编译运行以下程序后,关于输出结果的说明正确的是()。 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.编译错误

点击查看答案
第5题
以下程序的编译和运行结果为?abstract class Base{abstract public void myfunc();public void

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

abstract class Base{

abstract public void myfunc();

public void another(){

System.out.println("Another method");

}

}

public class Abs extends Base{

public static void main(String argv[]){

Abs a = new Abs();

A.amethod();

}

public void myfunc(){

System.out.println("My Func");

}

public void amethod(){

myfunc();

}

}

A.输出结果为 My Func

B.编译指示 Base 类中无抽象方法

C.编译通过,但运行时指示Base 类中无抽象方法

D.编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法。

点击查看答案
第6题
以下程序的编译运行结果为: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

点击查看答案
第7题
以下的程序的调试结果为?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. 编译错误

点击查看答案
第8题
当你编译运行下列程序代码,会得到什么结果?

private class Base{ Base(){ int i = 100; System.out.println(i); } }

public class Pri extends Base{ staticint i = 200;

public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }

A.这段代码不能通过编译

B.输出200

C.输出100和200

D.输出100

点击查看答案
第9题
以下程序的运行结果为()public class IfTest{public static void main(String args[]){int x=3;

A.Not equal

B.Equal

C.无输出

D.编译出错

点击查看答案
第10题
以下程序的运行结果为:public class My{int value;public static void main(String args[]) {My x=new My();if (x==null)System.out.println("No Object");elseSystem.out.println(x.value);}}

A. 0

B. 1

C. No Object

D. 编译错误

E. null

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