更多"下列是一个类的定义程序段,请补充完整。
public clas"的相关试题:
[填空题]下列是一个类的定义程序段,请补充完整。
public class My Class
int x,y;
MyClass(int i, 【11】 )
x=i;y=j;
[填空题]下列是一个类的定义程序段,请补充完整。
public class My Class {
int x,y; MyClass(int i,【 】) {
x=i;y=j;
}
}
[单项选择]有下面程序段:
Public class ArrayTest
Public static void main(String args[])
int[] intArray=new int[3];
for(int I=0;I<3;I++)
intArray[I]=I+2;
System.out.println("IntArray["+I+"]"="+intArray[I]);
System.out.println("--------------");
Int arrLen=4;
IntArray=new int[arrLen];
For(int j=intArray.length;j>=0;j--)
intArray[j]=j*3;
System.out.println("hello"+intArray[j]);
则运行的结果是( )。
A. 编译出错
B. 编译通过,但运行出错
C. 可以运行,但有错误
D. 以上都不对
[单项选择]有下面程序段:
Public class ArrayTest
Public static void main(String args[])
int[] intArray=new int[3];
for(int I=0;I<3;I++)
intArray[I]=I+2;
System.out.println("IntArray["+I+"]"-"+intArray[I]);
System.out.println("------------");
Int arrLen=4;
IntArray=new int[arrLen];
For(int j=intArray.length;j>=0;j--
intArray [j]=j*3;
System. out.println("hello"+intArray[j]);
则运行的结果是( )。
A. 编译出错
B. 编译通过,但运行出错
C. 可以运行,但有错误
D. 以上都不对
[单项选择]有如下程序段:
public class Parent
public int addValue (int a,int b)
int s;
s=a+b;
return 3;
class Child extends Parent
则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。
A. int addValue (int a,intb) //do something...
B. public void addValue() //do something...
C. public int addValue (int a,intb)throws MyException //do something...
D. public float addValue (int a,int b,float b=1.0) //do someting...
[单项选择]阅读下面的程序段:
publiC class Sun
public static void main (String args[ ])
int a=0;
for(int i=1;i<=3;i++)
for(int j=1;j<=i;j++)
for(int k=j;k<=3;k++)
a=a+1;
System.out.println(
A. ;
B. 9
C. 14
D. 21
[单项选择]下面程序段的输出结果为
public class Test
public static void main(String args[])
boolean a,b,c;
a=(3<5);
b=(a==true);
System.out.printin( "a="+a+"b="+b) ;
c-(b==false);
System.out.println(b="+b+"e="+c) ;
A. a=true b=false
B. a=true b=false
C. a=true b=true
D. a=false b=false
[单项选择]下面程序段的输出结果是
public class Test
public static void main(Stringargs[])
int x,y;
x=(int)Math.sqrt(5)/2+(int)Math.random( )*5/2;
y=(int)Math.sqrt(3)/2+(ht)Math.random( )*3/2;
if(x>y)
System.out.println(”x>y”);
else if(x=y)
System.out.println(”x=y”);
else
System.out.Println(”x<y”);
A. x>y
B. x=y
C. x<y
D. 编译错误
[单项选择]阅读下面的程序段: public class Sun { public static void main(String args[ ]) { int a=0 for(int i=1;i<=3;i++) { for(int j=1;j<-i;j++) { for(int k=j;k<=3;k++) { a=a+1; } } } System.out.println(A) 我; }}执行上面的3重循环后,a的值为( )。
A. 3
B. 9
C. 14
D. 21
[单项选择]下面程序段的输出结果为
public class Test
public static void main(String args[])
boolean a,b,c;
a=(3<5);
b=(a==true);
System.out.println("a="+a+"b="+b);
c=(b==false);
System.out.println("b="+b+"c="+c);
A. a=true b=false
B. a=true b=false
C. a=true b=true
D. a=false b=false
[单项选择]下面程序段的输出结果是
public class Test
public static void main(String args[])
int[] a=new int[11];
int[] p=new int[4];
int k=5;
for(int i=1;i<=10;i++)
a[i]=i;
for(int i=l;i<=3;i++)
p[i]=a[i*i];
for(int i=1;i<=3;i++)
k=k+p[i]*2;
System.out.println(k);
A. 37
B. 31
C. 33
D. 35