举一反三
- 给出下面代码段 1) public class Test { 2) int m, n; 3) public Test() {} 4) public Test(int a) { m=a; } 5) public static void main(String arg[]) { 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) } 哪行将引起一个编译时错误?
- 下列代码中,将引起一个编译错误的行是( )。 1) public class Test 2) int m,n; 3) public Test() 4) public Test(int A: m=a; B: 5) public static void main(String args[]) C: 6) Test t1,t2; D: 7) int j,k; E: 8) j=0;k=0; F: 9) t1=new Test(); G: 10) t2=new Test(j,k); H: 11) I: 12) A) 第3行 J: 第5行 K: 第6行 L: 第10行
- 23、给出下面代码段 1) public class Test { 2) int m, n; 3) public Test() {} 4) public Test(int a) { m=a; } 5) public static void main(String arg[]) { 6) Test t1,t2; 7) intj,k; 8) j=0;k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12) } ( )行将引起一个编译时错误。 A: line 3 B: line 5 C: line 6 D: line 10
- 分析程序,将代码补充完整public class Test { ________ __ int k=5; public static void main(String[] args){ Test t1=new Test(); t1.k++; System.out.println(Test.k); }}
- public class test { public static void main(String args[]) { int m=0; for ( int k=0;k<2;k++) method(m++); System.out.println(m); } public static void method(int m) { System.out.print(m); } }
内容
- 0
下列代码的执行结果是 。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();}}
- 1
已知有下列类的说明,则下列哪个语句是正确的?public class Test {private float f = 1.0f;int m = 12;static int n=1;public static void main(String arg[]) {Test t = new Test();}}
- 2
(6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }
- 3
下列程序的运行结果是()。 public class Test public static void main ( String [ ] args ) int count = 0 for( int i = 1 i < 5 i = 2) for( int j = 1 j< = 10 j = 3) count System .out .print (count ) _
- 4
public class Test { public static void main(String[] args) { int a = 4,b = 9,k = 0; while((a++) A: 4 B: 1 C: 2 D: 3