int [] my_Array; My_Array=new int [5]; For(int count = 0 ; count <=5; count ++) System.out.pringtln(my_Array[count]); 以上Java代码运行的结果是()
第1题:
A.将1,2,3,4,5输出到屏幕
B.将0,1,2,3,4输出到屏幕
C.将0,1,2,3,4,5输出到屏幕
D.将出现运行时异常
第2题:
下面程序的运行结果是【 】。
inChlde<iOStream>
using namespace std;
class count
{
static int n;
public:
count()
{
n++;
}
static int test()
{
for(int i=0:i<4;i++)
n++;
return n;
}
};
int count::n=0;
int main()
{
cout<<COUnt::test()<<" ";
count c1, c2;
cout<<count::test()<<end1;
return 0;
}
第3题:
A.将1,2,3,4,5输出到屏幕
B.将0,1,2,3,4输出到屏幕
C.将0,1,2,3,4,5输出到屏幕
D.将出现运行时异常
第4题:
( 35 )有如下程序:
#include <iostream>
using namespace std;
Class B{
public:
B(int xx):x(xx) {++cout; x+=10;}
virtual void show() const
{cout<<count<< ' _ ' <<x<<endl;}
protected:
static int count;
private:
int x;
};
class D:public B{
public:
D(int xx,int yy):B(xx),y(yy) {++count; y+=100;}
virtual void show() const
{cout<<count<< ' _ ' <<y<<endl;}
private:
int y;
};
int B::count=0;
int main(){
B *ptr=new D(10,20);
ptr->show();
delete ptr;
return 0;
}
运行时的输出结果是
A ) 1_120
B ) 2_120
C ) 1_20
D ) 2_20
第5题:
( 27 )有如下程序:
#include <iostream>
using namespace std;
class Toy{
public:
Toy(char* _n) { strcpy (name,_n); count++;}
~Toy(){ count--; }
char* GetName(){ return name; }
static int getCount(){ return count; }
private:
char name[10];
static int count;
};
int Toy::count=0;
int mail(){
Toy t1("Snoopy"),t2("Mickey"),t3("Barbie");
cout<<t1.getCount()<<endl;
return 0;
}
运行时的输出结果是
A ) 1
B ) 2
C ) 3
D )运行时出错
第6题:
如下程序的输出结果是______。
include<iostream>
using namespace std;
class pumpkin{
public:
pumpkin( ){++count;}
~pumpkin( ){--eount;}
static void total_count( ){cout<<count<<"pumpkin(s)"<<endl;}
private:
static int count;
};
int pumpkin::count=0;
int main( ){
pumpkin pl[10];
pumpkin::total_count( );
return 0;
}
第7题:
( 27 )有如下程序:
#include<iostream>
using namespace std;
class MyClass{
public:
MyClass(){++count;}
~MyClass(){--count;}
static int getCount(){return count;}
private:
static int count;
};
int MyClass::count=0;
int main(){
MyClass obj;
cout<<obj.getCount();
MyClass*ptr=new MyClass;
cout<<MyClass::getCount();
delete ptr;
cout<<MyClass::getCount();
return 0;
}
程序的输出结果是
A ) 121
B ) 232
C ) 221
D ) 122
第8题:
A.将1,2,3,4,5输出到屏幕
B.将0,1,2,3,4输出到屏幕
C.将0,1,2,3,4,5输出到屏幕
D.将出现运行时异常
第9题:
下面C程序中,设变量count的地址为20000。则该段程序执行后,屏幕上的显示结果应为(53)。 # include <stdio.h> main(void) { int count, q; int *m; count = 100; m = &count; q = *m; printf("q=%d; \n", q); return 0; }
A.q=2000;
B.q=2000
C.q=100;
D.q=100
第10题:
有如下程序: #include <iostream> using namespace std; class MyClass { public: MyClass() { ++count; } ~MyClass() { --count; } static int getCount() { return count; } private: static int count; }; int MyClass::count=0; int main() { MyClass obj; cout<<obj.getCount(); MyClass *ptr=new MyClass; cout<<MyClass::getCount(); delete ptr; cout<<MyClass::getCount(); return 0; }程序的输出结果是
A.121
B.232
C.221
D.122