下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }
A.false
B.true
C.1
D.0
第1题:
有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return 0; } 执行后的输出结果是( )。
A.n=0
B.n=1
C.n=2
D.n=3
第2题:
请将下列程序的横线处补充完整,使得输出结果为bbaa
include<iostream>
using namespace std;
class A{
public:
______{cout<<"aa";}
};
class B:public A{
public:
~B(){cout<<"bb";}
};
int main(){
B*p=new
第3题:
使用VC6打开考生文件夹下的工程test17_1,此工程包含一个源程序文件test17_1.唧,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
Vehicle message
Car message
Vehicle message
源程序文件test17_1.cpp 清单如下:
include <iostream.h>
class vehicle
{
int wheels;
float weight;
public:
/***************** found *****************/
void message(void){ cout<<"Vehicle message\n";}
};
class car:public vehicle
{
int passenger_load;
public:
/***************** found *****************/
void message (void){cout>>"Car message\n";}
};
class truck:public vehicle
{
int passenger_load;
float payload;
public:
int passengers(void){return passenger_load;}
};
void main()
{
vehicle * unicycle;
unicycle=new vehicle;
/***************** found *****************/
unicycle.message()
delete unicycle;
unicycle=new car;
unicycle->message();
delete unicycle;
unicycle=new truck;
unicycle->message();
delete unicycle;
}
第4题:
请写出下面的输出:
class B
{
public:
virtual void Print(void)
{
printf(“B::Print\n”);
}
virtual void Reprint(void)
{
printf(“B:Reprint\n”);
}
void Algo(void)
{
Print();
Reprint();
}
};
class D : public B
{
public:
virtual void Print(void)
{
printf(“D::Print\n”);
}
};
void main()
{
B *p = new D();
p->Print();
p->Algo();
}
第5题:
有如下程序: #include <iostream> using namespace std; class Test { public: Test() {n+=2; } ~Test() {n-=3; } static int getNum() {return n; } private: static int n; }; int Test::n=1; int main() { Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return 0; } 执行该程序的输出结果是( )。
A.n=0
B.n=1
C.n=2
D.n=3
第6题:
如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} static int getNum( ){return n;} private: static int n; }; int Test::n=1; int main( ){ Test*P=new Test: delete P; cout<<"n="<<Test::getNum( )<<endl; return 0; }
A.n=0
B.n=1
C.n=2
D. n=3
第7题:
有如下程序:#include <iostream>using namespace std:class Test{public: Test() {n+=2; ~Test() {n-=3; ; static int getNum() {return n;}privaue: static int n:};int Test::n=1;int main(){ Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<end1; return 0;} 执行后的输出结果是
A.n=0
B.n=1
C.n=2
D.n=3
第8题:
下列程序的运行结果是【 】。
include <iostream. h>
class SomeClass
{
public:
SomeClass(int value) { some_value=value;};
void show_data(void) { cout<<data<<"<<~some_value<<endl; };
static void set_data(int value) {data=value; }
private:
static int data;
int some_value
};
int SomeClass::data
void main(void)
{
SomeClass my_class(1001),your_class(2002);
your_class. set_data(4004);
my_elass. show_data()
}
第9题:
有如下程序: #include <iostream> using namespace std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){retum n;} private: static int n; }; int Test:: n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test:: getNum()<<end1; return 0; };执行后的输出结果是______.
A.n=0
B.n=1
C.n=2
D.n=3
第10题: