下列代码中,将引起编译错误的行是( )。 ① public class test{ ② public static void main(String args[]){ ③ float f=0.0; ④ f+=1.0; ⑤ } ⑥ }
A.第2行
B.第3行
C.第4行
D.第6行
第1题:
下列代码的执行结果是( )。 public class Test { public static void main ( String args[]) { float f=5.0f; int i=4; System.out.println((f++) *(--i)); } }
A.20
B.20.0
C.15
D.15.0
第2题:
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}
A.编译错误
B.0
C.1
D.运行成功,但不输出
第3题:
下列代码中,将引起一个编译错误的行是 1) public class Test{ 2) int m,n; 3) public Test(){} 4) public Test(inta){m=a;} 5) public static void main(String args[]){ 6) Test t1,t2; 7) int j,k; 8) j=0;k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12) }
A.第3行
B.第5行
C.第6行
D.第10行
第4题:
下面程序片段的执行中,说法正确的是( )。 public class Test { public static void main (String args[]) { byte y=20; int i=y; int x=100; y=x; System.out.println(y); } }
A.输出y的值为100
B.第4行错误
C.输出y的值为20
D.第6行错误
第5题:
下列代码执行结果为 ( )public class Test{ public static void main(String args[]){ float p=0f; int q=3; System.out.println(++p)*(q--)); }}
A.16
B.24
C.16
D.24
第6题:
下列代码中,将引起编译错误的行是( )。 1) public class Exercise{ 2) public static void main(String args[]) { 3) float f=0.0; 4) f+=0; 5) } 6) }
A.第2行
B.第3行
C.第4行
D.第6行
第7题:
下列程序段执行后,变量c的值为( )。public class Test { public static void main(String[ ] args) { float a=10, b=9, c=8; if (--a==B) c= --a/c; System.out.println (c) ; } }
A.1.125
B.1.0
C.1.25
D.0.0
第8题:
对下列程序的叙述中,正确的是( )。 1)public class X extends Thread implements Runnable{ 2)public void run{ 3)system.out.println("this is run"); 4)} 5)public static void main(String args[]){ 6)Thread t=new Thread(new X); 7)t.start; 8)} 9)}
A.第l行会产生编译错误
B.第6行会产生编译错误
C.第6行会产生运行错误
D.程序正常运行
第9题:
执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }
第10题:
public class Test { private static float[] f = new float[2]; public static void main(String args[]) { System.out.println(“f[0] = “ + f[0]); } } What is the result?()
第11题:
f[0] = 0
f[0] = 0.0
Compilation fails.
An exception is thrown at runtime.
第12题:
输出171.0
输出171
第2行和第5行编译报错
第10行编译报错
第13题:
下列代码中,将引起编译错误的行是( )。 1)publicclassExercise{ 2)publicstaticvoidmain(Stringargs[]){ 3)floatf=0.0; 4)f+=1.0; 5)} 6)}
A.第2行
B.第3行
C.第4行
D.第6行
第14题:
阅读下面代码 public class Test implements Runnable { public void run(Thread t) { System.out.println("Running"); } public static void main(String[] args) { Thread tt=new Thread(new Test()); tt.start(); } } 代码运行的结果是
A.将抛出一个异常
B.没有输出并正常结束
C.输出“Running”并正常结束
D.程序第2行将出现一个编译错误
第15题:
已知有下面的类说明: public class Test4 { private float f=1.0f; int m=12; static int n=1; public static void main(String args[]) { Test4 e=new Test4(); } } 在main()方法中,下面哪个的使用是正确的? ( )
A.e.f
B.this.n
C.Test4.m
D.Test4.f
第16题:
下列代码中,将引起编译错误的行是( )。 1)public class Exercise{ 2)public static void main(String args[]){ 3)floatf=0.0; 4)f+=1.0; 5)} 6)}
A.第2行
B.第3行
C.第4行
D.第6行
第17题:
下列代码中,将引起编译错误的行是______。 (1) public class Test { (2) int m,n; (3) public Test( ){} (4) public Test(int A){m=a;} (5) public static void main(String args[ ]){ (6) Test t1,t2; (7) int j,k; (8) j=0;k=0; (9) t1=new Test( ); (10) t2=new Test(j,k); (11) 1 (12) }
A.第3行
B.第5行
C.第6行
D.第10行
第18题:
下列代码的执行结果是( )。 public class Test{ public static void main(String args[ ]){ float t=9.0f; int q=5; System.out.println((t++) * (- -q)); } }
A.41
B.41.0
C.36
D.36.0
第19题:
对下列程序的叙述中,正确的是( )。 1:public class X extends Thread implements Runnable{ 2:public void run{ 3:system.out.println("this is run"); 4:} 5:oublic static void main(String args[]){ 6:Thread t=new Thread(new X): 7:t.start; 8:} 9:}
A.第l行会产生编译错误
B.第6行会产生编译错程
C.第6行会产生运行错误
D.程序正常运行
第20题:
执行下面程序,输出的结果是?() public class Test{ public static void main(String[] args){ int a = 5; double b = 8; a = a++ + b; System.out.println(a); } }
第21题:
在Java中,下列代码将输出()。 1. public class integerequals 2. { 3. public static void main (String args[]) 4. { 5. Integer a= new Integer(3); 6. Integer b= new Integer(3); 7. System.out.println(a==b); 8. } 9. }
第22题:
第4行编译报错
第5行编译报错
编译成功,输出13
编译成功,输出14
第23题:
输出null
第10行编译报错
第11行编译报错
输出Jema