以下程序的运行结果为: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
A. 3
B. 4
C.5
D.6
E.7
A.Not equal
B.Equal
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.编译错误
A. 输出结果为 0
B. 运行出错
C. 输出结果为 null
D. 编译错误
A. goodmorning
B. "good"+"morning"
C. good morning
D. good+morning
A. 5
B. x=5
C. "x="+5
D. "x="5
以下程序的编译运行结果为:
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
以下程序的运行结果为?
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
A. 0
B. 1
C. 2
D.3
以下程序的运行结果为?
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
以下程序的编译和运行结果为?
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方法无方法体,没谁会喜欢该方法。