更多"#include<iostream.h> class test "的相关试题:
[单项选择]执行下面程序段,屏幕上将输出( )。
public class Test
private int x=10,y=20;
public Test (int x,int y)
System.out.println (x+this.x);
System.out.println (y+y);
public static void main (String[] args)
Testt= new Test(30,50);
A. 无输出
B. 20
C. 40
D. 40
[单项选择]下面程序的结果是
#include<iostream.h>
class test private:
int num;
public:
test( );
int getint( ) return num;
~test( );;
test::test( )
num=0;
test::~test( )
cout<<"Destructor is active"<<endl;
void main( )
test x[3];
cout<<"Exiting main"<<endl;
A. Exiting main
B. Exiting main
C. Exiting main
D. Exiting main
[简答题]完成下面类中成员函数的定义。
class test
private:
int n1;
float f1;
public:
test(int,float f);
test(test&);
;
test::test(______)
n1=n;f1=f;
test::test(test&t)
n1=t.n1;n=______;
[单项选择]下列程序的运行结果是______。
public class test
private String [] data="10","10.5");
public void fun( )
double s=0;
for(int i=0; i<3; i++)
try
s=s+Integer. parseInt(data[i]);
catch(Exception e)
System. out. print("errorl:"+data[i]);
public static void main(string [] args)
try
test d=new test( );
d. fun( );
catch(Exception e)
System. Out. println("error2")
A. error1:10.5
B. error2
C. error1:10.5 error2
D. 以上都不对
[填空题]根据输出结果填空完成下面程序。
#include<iostream.h>
class Test
private:
static int val;
int a;
public:
static int func( );
void sfunc(Test &r);
;
______//初始化静态变量val
int Test::func( )
return val++;
void Test::sfunc(Test &r)
r.a=125;
cout<<"Result3="<<r.a;
void main( )
cout<<"Resultl="<<Test::func( )<<endl;
Test A;
cout<<"Result2="<<A.fune( )<<endl;
A. sfunc(A);
输出结果为:
Result1=201
Result2=202
Result3=125
[简答题]运行程序,写出程序执行的结果。
#include<iostream.h>
class Test
private:
static int val;
int a;
public:
static int func( );
static void sfunc(Test &r);
;
int Test::val=20:
int Test::func( )
val--;
return val;
void Test::sfunc(Test &r)
r.a=25;
cout<<"Result3="<<r.a<<endl;
void main( )
cout<<"Resuh1="<<Test::func( )<<endl;
Test a;
cout<<"Result2="<<a.func( )<<endl;
Test::sfunc(a);
[单项选择]命令按钮控件test的单击事件过程如下:
Private Sub test_click( )
Dim I,R
R=0
For I=1 T0 5 Step 1
R=R+I
Next I
bResult.Caption=Str(R)
End Sub
当运行窗体,单击命令按钮时,在名为bResuh的窗体标签内将显示的是______。
A. 字符串15
B. 字符串5
C. 整数15
D. 整数5
[单项选择]有下列命令按钮控件test的单击事件过程:
Private Sub test_click( )
Dim I,R
R=0
For I=1 To 5 Step 1
R=R+I
Next I
bResult.Caption=Str(R)
End Sub
当运行窗体,单击命令按钮时,在名为bResult的窗体标签内将显示的是______。
A. 字符串15
B. 字符串5
C. 整数15
D. 整数5
[简答题]#include<iostream.h>
class Add
private:
int sum;
public:
void plus(int,int);
;
void Add::plus(int x,int y)
sum=x+y;
void main( )
Add add;
add.plus(2,3);
cout<<add.sum<<endl;
[填空题]#include<iostream.h>
class f
private:
float x,y;
public:
void f1(float a,float b)x=a;y=b;
f( )x=0;y=0;
void move(float a,float b)x=x+a;y=y-b;
void get( )cout<<x<<’ ’<<y<<endl;
;
void main( )
f *p,a;
a.f1(1.6,3.8);
p=&a;
p.get( );
[简答题]#include<iostream.h>
class A
private:
int X,Y;
public:
A( )X=Y=0;
A(int xx,int yy):X(xx),Y(yy)
A(A&a) ______;
int GetX( ) return X;
int GetY( )return Y;
void SetXY(int x,int y) X=x;Y=y;
;
void main( )
A*Ptr=new A[2];
Ptr[0].SetXY(5,10);
Ptr[1].SetXY(15,20);
cout<<"Release Ptr……"<<endl;
______;//释放动态分配内存
[填空题]类Test定义如下:
public class Test{
public static void main(String args[])
{
String sty=new String("abcde");
char ch[]={’A’,’B’,’C’,’D’,’E’};
ml(str,ch);
System.out.print(str+",");
System.out.println(ch);
}
public static void ml(String s,char ch[])
{
s="Hello";
ch[3]=’Z’;
}
}
那么程序的执行结果为: 【9】
[单项选择]有如下程序 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 a=12 b=45
B. a=12 b=45 a=100 b=200
C. a=12 b=200 a=100 b=45
D. a=100 b=45 a=12 b=200
[单项选择]下面程序段的输出结果为
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 Objl=new Test(12,45);
System.out.println("a="+objl.a+" b="+Objl.b);
Test Obj2=new Test( );
System.out.println("a="+Obj2.a+" b="+Obj2.b);
A. a=100 b=200
B. a=12 b=45
C. a=12 b=200
D. a=100 b=45