更多"有以下程序: class Date { public: D"的相关试题:
[单项选择]有以下程序:
Class Date
public:
Date(int y,int m,int d);
year=y;
month=m;
day=d;
Date(int y=2000)
year=y;
month=10;
day=1;)
Date(Date &d)
year=d.year;
month=d.month;
day=d.day;
void print( )
cout<<year<<“.”<<month<<“.”<<day<<endl;
private:
int year,month,day;;
Date fun(Date d)
Datetemp;
temp=d;
return temp;
int main( )
Date date1(2000,1,1),date2(0,0,0);
Date date3(datel);
date2=fun(date3);
return 0;
程序执行时,Date类的拷贝构造函数被调用的次数是( )。
A. 2
B. 3
C. 4
D. 5
[单项选择]有以下程序:
class Date
public:
Date(int y, int m, int d);
year = y;
month = m;
day = d;
Date(int y = 2000)
year = y;
month = 10;
day = 1;
Date(Date &d)
year = d.year;
month = d.month;
day = a.day;
void print( )
cout<<year<<"."<<month<<"."<<day<<end1;
private:
int year, month,day;
;
Date fun(Date d)
Date temp;
temp = d;
return temp;
int main( )
Date date 1 (2000,1,1),date2(0,0,0);
Date date3(date 1);
date2 = fun(date3);
return 0;
程序执行时,Date 类的拷贝构造函数被调用的次数是
A. 2
B. 3
C. 4
D. 5
[单项选择]有以下程序: class Date { public: Date(int y,int m,int D) ; { year =y; month=m; day=d; } Date(int y=2000) { year=y; month=10; day=1; } Date(Date &D) { year=d.year; month=d.month; day=d.day; } void print ( ) { cout<<year<<"."<<month<<"."<<day<<end1; } private: int year,month,day; }; Date fun(Date D) { Date temp; temp=d; return temp; } int main( ) { Date date1(2000,1,1),date2(0,0,0); Date date3(date1); date2=fun(date3); return 0; } 程序执行时,Date类的拷贝构造函数被调用的次数是
A. 2
B. 3
C. 4
D. 5
[单项选择]有以下程序: Class Date { public: Date(int y,int m,mt d); { year=y; month=m; day=d; } Date(int y=2000) { year=y; month=10; day=1; } Date(Date &d) { year=d.year; month=d.month; day=d.day; } Void print( ) { cout<<year<<"."<<month<<"."<<day<<endl; } private: int year,month,day; }; Date fun(Date d) { Date temp; temp=d; return temp; } mt main( ) { Date date1(2000,1,1),date2(0,0,0); Date date3(datel); date2=fun(date3); return 0; } 程序执行时,Date类的拷贝构造函数被调用的次数是( )。
A. 2
B. 3
C. 4
D. 5
[单项选择]有以下程序:
class Date
{
public:
Date(int y,int m,int d);
{
year=y;
month=m
day=d;
}
Date(int y=2000)
{
year=y;
month=10;
day=1;
}
Date(Date &d)
{
year=d.year;
month=d.month;
day=d.day;
}
void print( )
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
private:
int year,month,day;
};
Date fun(Date d)
{
Date temp;
temp=d;
return temp;
}
int main( )
{
Date datel(2000,1,1),date2(0,0,0);
Date date3(datel);
date2=fun(date3);
return 0;
}
程序执行时,Date类的拷贝构造函数被调用的次数是
A. 2
B. 3
C. 4
D. 5
[单项选择]有以下程序:
class Date
public:
Dare(int y,int m,int d);
year=y;
month=m;
day=d;
Date(int y=2000)
year=y;
month=10;
day=1;
Date(Date &d)
year=d.year;
month=d.month;
day=d.day;
void print( )
cout<<year(<"."<<month<<"."<<day<<end1;
private:
int year,month,day;
;
Date fun(Date d)
Date temp;
temp=d;
return temp;
int main( )
Date date1(2000,1,1),date2(0,0,0);
Date date3(date1);
date2=fun(date3);
return 0;
程序执行时,Date类的拷贝构造函数被调用的次数是( )。
A. 2
B. 3
C. 4
D. 5
[单项选择]有如下程序
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 Person
int arr[ ]=Hew int[10];
public static void main(String args[ ])
System.out.println(arr[1]);
正确的说法是______。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出为0
D. 输出为空
[单项选择]下面程序段的输出结果为
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
[填空题]阅读并完成程序。
public class Class27
int m,n;
public______
public______m=a;
public static void main(String args[])
Class27 t1,t2;
int j=0;
t1=new Class27( );
t2=new Class27(j);
[简答题]阅读下列程序,请写出该程序的输出结果。
public class C
int x=10;
static int y=20;
public static void main(String[] args)
C obj1=new C( );
C obj2=new C( );
obj1.x*=2;
obj1.y*=3;
obj2.x+=4;
obj2.y+=5;
System. out. println(obj1.x);
System. out. println(obj1.y);
System. out. println(obj2.x);
System. out. println(obj2.y);
[单项选择]下列程序段的输出结果是______。
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="+Obj1.B);
Test Obj2=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 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...
[单项选择]下面程序段的输出结果为( )。
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="+Obj1.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