更多"有如下程序; public class MethTest { "的相关试题:
[单项选择]有如下程序:
public class MethTest
static int Var1=100;
int Var2=200;
public static void main(String args[])
Var1=10;
MethTest Obj1=new MethTest( );
MethTest Obj2=new MethTest( );
Obj1.Var1 ++;
System.out.println(Obj1.Var1);
Obj2.Var1 ++;
System.out.println(Obj2.Var1);
MethTest.Var1 ++;
System.out.println(Obj1.Var1);
Obj1.Var2 ++;
System.out.println(Obj1.Var2);
0bj2.Var2 ++;
System.out.println(Obj2.Var2);
程序的运行结果为( )。
A. 11
B. 101
C. 11
D. 10
[单项选择]有如下程序;
public class MethTest
static int Varl=100;
int Var2=200;
public static void main(String args[])
Varl=10;
MethTest Obj1=new MethTest( );
MethTest Obj2=new MethTest( );
Obj1.Varl++;
System.out.println(Objl.Varl);
Obj2.Varl++;
System.out.println(Obj2.Varl);
MethTest.Varl++;
System.out.println(Objl.Varl);
Obj1.Var2++;
System.out.println(Obj1.Var2);
Obj2.Var2++;
System.out.println(Obj2.Var2);
程序的运行结果为( )。
A. 11
B. 101
C. 11
D. 10
[单项选择]下面程序的运行结果为( )。
class A
static int n;
public:
A( )n=1;
A(int num)n=num;
void print( )cout<<n;
A::n=0;
void main( )
A a,b(2);
a.print( );
b.pint( );
A. 12
B. 11
C. 22
D. 21
[单项选择]有如下过程代码:
Sub var_dim( )
static numa As Integer
Dim numb As Integer
numa=numa+2.
numb=numb+1
print numa;mub
End Sub
连续3次调剧var_dim过程,第3次调用时的输出是( )。
A. 2 1
B. 2 3
C. 6 1
D. 6 3
[单项选择]有以下程序:
int a=2;
int f(int n)
{static int a=3;
int t=0;
if(n%2){ static int a=4; t+=a++; } else { static int a=5; t+=a++; } return t+a++;
}
main( )
{ int s=a,i; for(i=0;i<3;i++) s+=f(i); printf("%d/n",s);
}
程序运行后的输出结果是______。
A. 26
B. 28
C. 29
D. 24
[填空题]若有如下程序:
void sub( )
static int x=6;
x/=2;printf("%d",x);
main( )
int m;
for(m=0;m<=2;m++) sub( );
则程序运行后的输出结果是 【17】 。
[单项选择]有如下程序段:
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...
[单项选择]若有程序
fun(int a,int b)
static int c=0
c+=a+b;
retum c;
main( )
int x=5,y=3,z=7,r;
r=fun((y,x+y),z);
r=fun(x,y);
printf("%d/n",r);
上面程序的输出结果______。
A. 23
B. 15
C. 19
D. 18
[填空题]若有如下程序:
void sub( )
static int x=8;
x/=2;printf("%d",x);
main( )
int m;
for(m=0;m<2;m++) sub( );
则程序运行后的输出结果是 【9】 。
[单项选择]有以下程序:
int fun(int x[],int n)
static int sum=0,i;
for(i=0;i<n;i++)sum+=x[i];
return sum;
main( )
int a[]=1,2,3,4,5,b[]=6,7,8,9,s=0;
s=fun(a,5)+fun(b,4);printf("%d/n",s);
程序执行后的输出结果是( )。
A. 45
B. 50
C. 60
D. 55
[单项选择]有以下程序
int a=2;
int f(int n)
static int a=3;
int t=0;
if(n%2) static int a=4; t+=a++;
else static int a=5; t+=a++;
return t+a++;main( )
int s=a, i;
for( i=0; i<3; i++) s+=f(i);
printf("%d/n", s);程序运行后的输出结果是______。
A. 26
B. 28
C. 29
D. 24
[单项选择]有如下程序
public class Test
int a,b;
Test ( )
a = 100;
b = 200;
Test(int x, int y)
a = x;
b = y;
public static void main(String args[])
Test Obj1 = new Test(12,45);
System.out.println("a = "Obj1.a+" b = "+Ob31.B) ;
Test Obj1 = new Test( );
System.out.println("a = "Obj1.a+" b = "+Obj1.B) ;
程序的运行结果为( )。
A. a=100 b=200
B. a=12 b=45
C. a=12 b=200
D. a=100 b=45
[单项选择]有如下程序
public class Sun
public static void main(String args[ ])
int x=0;
int n=0;
while(x<50)
x=(x+2)*(x+3);
n=n+1;
System.out.println(n+"和"+x);
上述程序的运行结果是( )。
A. 1和0
B. 2和72
C. 3和50
D. 4和168