编译和运行以下代码的结果为:public class MyMain{public static void main(String argv){System.out.println("Hello cruel world");}}
A.编译错误;
B.运行输出 "Hello cruel world";
C.编译无错,但运行时指示没有定义构造方法。
D.编译无错,但运行时指示没有正确定义main方法。
A.编译错误;
B.运行输出 "Hello cruel world";
C.编译无错,但运行时指示没有定义构造方法。
D.编译无错,但运行时指示没有正确定义main方法。
编译和运行以下代码结果为:
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".
以下代码的运行结果为:
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
A. hello
B. hello2
C. 编译报错
D. 运行报错,不能将串与整数相加
编译运行以下程序后,关于输出结果的说明正确的是()。 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.编译错误
以下程序的编译和运行结果为?
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方法无方法体,没谁会喜欢该方法。
以下程序的编译运行结果为:
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
A. 输出结果为 0
B. 运行出错
C. 输出结果为 null
D. 编译错误
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
A.Not equal
B.Equal
C.无输出
D.编译出错
A. 0
B. 1
C. No Object
D. 编译错误
E. null