下列代码的执行结果是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.运行成功,但不输出
第1题:
分析以下程序的执行结果【 】。
include <iostream. h>
class S{
int A[10];
public:
int &operator () (int);
};
int &S: :operator() (int x) {
return A[x];
}
void main() {
S a;
int i,j;
for (i=0; i<10; i++)
a(i)=i*2;
for (i=0; i<10; i++)
cout<<a(i)<<" ";
cout<<end1; }
第2题:
第3题:
下列代码段执行后,s的值为()。 int[] a = {1,2,3,4,5}; int s = 0; for(int i = 0 ; i < 5 ; i++) if(i % 2 ==0) s += a[i];
A.0
B.6
C.15
D.9
第4题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
virtual void func(int i){cout<<"class Base:"<<i<<end1;)
};
class Derived: public Base
{
public:
void func(double d){cout<<"class Derived:"<<d<<endl;}
};
void main( )
{
Base a,*p=a;
Derived b;
p=&b;
(*p).func(3.3);
}
第5题: