更多"写出此程序的执行结果: #include<iostream.h> "的相关试题:
[单项选择]列程序的运行结果为
#include
template
class FF
TT al,a2,a3;
public:
FF(TT b1,TT b2,TT b3)a1=b1;a2=b2;a3=b3;
TT Sum( )return al+a2+a3;;
void main( )
FFx(int(1.1),2,3),y(int(4.2),5,6);
cout< A. 6.1 15.2
B. 6 15
C. 6 15.2
D. 6.1 15
[单项选择]下列程序的运行结果为
#include<iostream.h>
template<class TT>
class FF
TT a1,a2,a3;
public:
FF(TT b1,TT b2,TT b3)a1=b1;a2=b2;a3=b3;
TT Sum( )return a1+a2+a3;;
void main( )
FF<int>x(int(1.1),2,3),y(int(4.2),5,6);
cout<<x.Sum( )<<‘‘<<y.Sum( )<<endl;
A. 6.1 15.2
B. 6 15
C. 6 15.2
D. 6.1 15
[单项选择]以下程序的执行结果是( )。
#include<iostream.h>
template<class T>
class Sample
T n:
public:
Sample(T i) n=i;
void operator++( );
void disp( )cout<<"n="<<n<<endl;
;
template<class T>
void Sample<T>::operator++( )
n+=1; // 不能用n++, 因为double型不能用++
void main( )
Sample<char>s(’a’);
s++;
s.disp( );
A. n=a
B. a=0
C. n=b
D. a=b
[填空题]#include<iostream.h>
template<class T>
class f
private:
T x,y;
public:
void f1(T a,T b)x=a;y=b;
T max( )return(x>y) x:y;
;
void main( )
f<int>a;
a.f1(3.5,3.8);
cout<<a.max( )<<endl;
[单项选择]下列程序的运行结果为( )。
#include
template
classFF
{TTa1,a2,a3;
public:
FF(TTb1,TTb2,TTb3){a1=b1;a2=b2;a3=b3;}
TTSum(){returna1+a2+a3;}};
voidmain()
{FFx(int(1.1),2,3),y(int(4.2),5,6);
cout<
A. 6.115.2
B. 615
C. 615.2
D. 6.115
[单项选择]下列程序执行结果是
#include<iostream.h>
class A
public:
int a;
A( ):a(10)tout<<a<<endl;
;
void main( )
A obj1;
A obj2(obj1);
cout<<" "<<obj2.a<<endl;
A. 10 10
B. 编译错误缺少拷贝构造函数
C. 10 随机数
D. 随机数随机数
[填空题]#include<lostream.h>
template<class T>
T minx(T x,T y)
if(x>y)
x=y;
return x;
void main( )
int a;
double d:
cout<<minx(a,d)<<endl;
[填空题]程序的结果为 【14】 。
#include"iostream.h"
template<typename T>
T total(T*data)
T s=0;
while(* data)
s+=*data++;
return s;
int main( )
int x[ ]= 2,4,6,8,0,12,14,16,18 ;
cout<<total(x);
return 0;
cout<<endl;
[单项选择]以下程序执行结果是 ( )。
#include <iostream.h>
class Base
public
virtual void fun( ) cout<<"B";
;
class Derived
public:
Derived( ) cout<<"D";
virtual void fun( ) Base::fun( ); cout<<"C";
int main ( )
Base *ptr;
Derived obj;
ptr=&obj;
p->fun ( );
return 0;
A. DBC
B. DCB
C. BDC
D. CBD
[填空题]请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
public class throwsExcepfion{
static void Proc(int se1)
throws ArithmeticException,ArraylndexOutOfBoundsException {
System.out.println("in Situation"+se1);
if(se1==0){
System.out.println("no Exception caught");
return;
}else if(se1==1){
int iArray[]=new int[4];
iArray [1]=3;
}
}
public static void main(String args[])[
try{
Proc(0);
Proc(1);
} catch(ArraylndexOutOfBoundsException e) {
System.out.println("Catch"+e);
}finally{
System.out.println("in Proc finally");
}
}
}
执行结果:
In Situation( )
no ExcepbOn cauSht
【14】
in Proc findly
[填空题]程序的结果为 【14】 。
#include"iostream.h"
template<typename T>
T total(T*data)
Ts=0;
while(*data)
s+=*data++;
return s;
int main( )
int x[] = 2,4,6,8,0,12,14,16,18 ;
cout<<total(X);
return 0;
cout<<endl;
[单项选择]下列程序的执行结果是 public class Testhh public static void main(String args [] ) Strings1=new String("I am boy"); Strings2=new String("I am boy"); System.out.println(s1.equals(s2));
A. true
B. false
C. I am boy
D. 都不正确
[单项选择]下列程序的执行结果是 public class Testff public static void main(String args[]) String sl=new String("I am boy"); String s2=new String("I am boy"); System.out.println(sl==s2);
A. true
B. false
C. "I am boy"
D. 都不正确