【单选题】【消耗次数:1】
给出下面代码段, 哪行将引起一个编译时错误?( ) 1) public class Test { 2) int n = 0; 3) int m = 0; 4) public Test(int a) { m=a; } 5) public static void main(String arg[]) { 6) Test t1,t2; 7) int j,k; 8) j=3; k=5; 9) t1=new Test(); 10) t2=new Test(k); 11) } 12) }
行1
行4
行6
行9
参考答案:
复制
纠错
相关题目
【单选题】 有以下程序,执行后输出结果是() main( ) { int m[][3]={1,4,7,2,5,8,3,6,9}; int i,j,k=2; for(i=0;i { printf(%d ,m[k][i]); } }
①  4 5 6
②  2 5 8
③  3 6 9
④  7 8 9
【单选题】 运行下面程序时,会产生什么异常?( ) public class X7_1_5 { public static void main(String[] args) { int[] z = { 1,2,3,4 } ; int p = z[4]; int x = 0; int y = 5/x; } }
①  ArithmeticException
②  NumberFormatException
③  ArrayIndexOutOfBoundsException
④  IOException
【单选题】 运行下面程序时,会产生什么异常?( ) public class X7_1_4 { public static void main(String[] args) { int x = 0; int y = 5/x; int[] z = { 1,2,3,4 } ; int p = z[4]; } }
①  ArithmeticException
②  NumberFormatException
③  ArrayIndexOutOfBoundsException
④  IOException
【单选题】 以下程序的运行结果是( )。 void fun(int array[3][3]) { int j; for(j=0;jj++) array[1][j]=array[1][j]++; printf(\n} void main(){ int j,a[3][3]={0,1,2,1,0,4,2,4,5};fun(a);for(j=0;jj++)printf(%d,a[1][j]); printf(\n }
①  1 0 4
②  2 1 5
③  0 1 2
④  1 2 3
【单选题】 以下程序的输出结果是()。 main( ) { int b[3][3]={0,1,2,0,1,2,0,1,2},i,j,t=0; for(i=0;i for(j=i;j t=t+b[i][b[j][j]]; printf(%d\n,t); }
①  3
②  4
③  1
④  9
【单选题】 下面程序的输出是 int fun3(int x) {static int a=3; a+=x; return(a); } void main() {int k=2,m=1,n; n=fun3(k); n=fun3(m); printf(%d\n }
①  3
②  4
③  6
④  9
【单选题】 下列程序的运行结果是( ) 。 public class X5_1_2 extends x{ int ab() { static int aa=10; aa++; System.out.println(aa); } public static void main(String[] args) { X5_1_2 x=new X5_1_2(); x.ab(); } }
①  10
②  11
③  编译错误
④  运行成功,但不输出
【单选题】 关于以下application的说明,正确的是( ) 1. class StaticStuff 2. { 3. static int x=10; 4. static { x+=5;} 5. public static void main(String args[ ]) 6. { 7. System.out.println(“x=” + x); 8. } 9. static { x/=3;} 10. }
①  4行与9行不能通过编译,因为缺少方法名和返回类型
②  9行不能通过编译,因为只能有一个静态初始化器
③  编译通过,执行结果为:x=5
④  编译通过,执行结果为:x=3
【单选题】 以下程序段运行后s的值是()。 int a[3][3]={1, 2, 3, 4, 5, 1, 2, 3, 4} ; int i, j, s=1; for(i=0; i for(j=i+1; j s+=a[i][j];
①  6
②  120
③  7
④  240
【单选题】 已知有下面类的说明: public class X5_1_1 extends x{ private float f =10.6f; int i=16; static int si=10; public static void main(String[] args) { X5_1_1 x=new } } X5_1_1(); 在 main()方法中,下面哪条语句的用法是正确的?( )
①  x.f
②  this.si
③  X5_1_1.i
④  X5_1_1.f
随机题目
【单选题】 流程控制类语句包括( )3类语句。
①  选择、循环、跳转
②  选择、循环、输入
③  选择、输入、输出
④  循环、选择、函数
【单选题】 在switch语句的每个case块中,假定都是以break语句结束的,则此switch语句容易被改写为( )语句。
①  for
②  if
③  do
④  While
【单选题】 每次先进行循环条件的判断,然后再执行循环体的语句是( )。
①  for和do
②  for和while
③  while和do
④  switch和break
【单选题】 假定a为一个字符数组名,则a[8]的地址比该数组的首地址大( )个字节。
①  4
②  8
③  16
④  32
【单选题】 在switch语句的每个case块中,假定都是以break语句结束的,则此switch语句容易被改写为( )语句。
①  for
②  if
③  do
④  While
【单选题】 假定一个二维数组的定义语句为“int a[3][4]={{3,4},{2,8,6}};”,则元素a[2][1]的值为( )。
①  0
②  4
③  8
④  6
【单选题】 当在程序中执行到( )语句时,将结束所在循环语句中循环体的一次执行。
①  continue
②  break
③  goto
④  return
【单选题】 在下面的do循环语句中,其循环体被执行的次数为( )。 int i=0;do i++;while(i*i<10);
①  4
②  3
③  5
④  2
【单选题】 假定有定义“int b[10];int *pb;”,则不正确的赋值语句为( )。
①  pb=b;
②  pb=
③  pb=b+2;
④  pb=b[5];
【单选题】 若需要把一个字符串aaa赋值到字符数组a中,则需要进行( )的函数调用实现。
①  strlen
②  strcmp
③  strcat
④  strcpy