更多"下列程序中,划线处正确的语句是( )。 #include<iost"的相关试题:
[单项选择]在下列程序的划线处应填入的语句是 ( )
class Person
private int a;
public class Man extends Person
public int b
public static void main(String arg[])
Person P=new Person( );
Man t=new Man( );
int i;
______
A. i=w;
B. i=b;
C. i=p.a;
D. i=t,b;
[单项选择]下列程序中划线处正确的语句是( )。
# include <iostream>
using namespace std;
class Base
public:
void fun( )cout<<"Base:: fun" <<endl;
;
class Derived:public Base
void fun( )
______ ∥显式调用基类的函数fun( )
cout<<"Derived:: fun"<<endl;
;
A. fun();
B. Base.fun();
C. Base::fun();
D. Base- >fun();
[单项选择]在下列程序的划线处应填入的语句是( )。 class Person private int a: public class Man extends Person public int b; public static void main(String arg []) Person p=newPerson( ); Man t=new Man( ); int i; _________________
A. i=w;
B. i=b;
C. i=P.a;
D. i=t.b;
[单项选择]在下列程序的划线处应填入的语句是
class Person
private int a;public class Man extends Person
public int b;
public static void main (String arg [])
Person p=new Person( );
Man t=new Man( );
int i:
A. i=w;
B. i=b
C. i=p.a;
D. i=t.b;
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是 【15】 。
#include <iostream. h>
class A
{
______
private:
int numl;
public:
A( ):numl(0){}
A(int i):numl(i){}
};
class B
{
private:
int num2
public:
B( ):num2(0){}
B(int i):num2(i){}
int my_math(A obj1,B obj2);
};
int B::my_math(A obj1,B obj2)
}
return (obj1.num1+obj2.num2);
}
void main(void)
{
A obj1 (4)
B obj,obi2(5);
cout <<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
[单项选择]下列程序中,划线处正确的语句是( )。
#include<iostream.h>
Class Base
Public:
Void fun( )cout<<"Base::fun"<<endl;
;
Class Derived:public Base
void fun( )
______ //显示调用基类的函数fun( )
Cout<<"Derived::fun"<<endl;
;
A. fun()
B. Base.fun()
C. Base::fun()
D. Base->fun();
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#include<iostream.h>
class A
private:
int numl;
public:
A( ):numl(0)
A(int i):numl(i)
;
class B
private:
int num2;
public:
B( ):num2(0)
B(int i):num2(i)
int my_math(A obj1, B obj2);
;
int B::my_math(A obj1,B obj2)
return(obj1.numl+obj2.num2);
void main(void)
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
[单项选择]为完成下面的程序,应在划线处填入的语句是
#include<iostream>
using namespace std;
class Base
private:
int x;
public:
Base (int i)
x=i;
~Base( )
;
class Derived:public Base
public:
______________//完成类Derive构造函数的定义
;
int main( )
Derived Obj;
return 0;
A. Derived(inti):Base(i)
B. Derived()
C. void Derived (inti):Base(i)
D. Derived(inti)Base(i);
[单项选择]下列选项中,对划线语句解释最准确的一项是:
A. 谴责撒谎者的依据是内心对是非、善恶的正确认识
B. 撒谎者自我谴责来自于他大脑中的前扣带回区域
C. 善良的心地是谴责撒谎者的依据
D. 撒谎者的自我谴责源于他大脑中“自我控制”区域的干预
[填空题]下列程序可完成求1至100之间的整数的和的功能。请在划线处编写适当语句,使此程序能正确执行。
public class Sum
public static void main(string args[])
int sum=0;
for(int i=1;i<=100;i++)
【13】 ;
System.out.println("sum="+sum);
[填空题]请在划线处编写适当语句,完成此程序使它能正确执行。
import java.io.*;
public class Leap Year
public static void main (String arget[]) throws IOException
InputStreamReader ir;
BufferedReader in;
ir=new Input Stream Reader (System.in);
in=new BufferedReader(ir);
System.out.println(“输入年份是:”):
String s=in.readLine( );
int year=Integer.parseInt(s);
System.out.println(" "+ year+“年是闰年。”);
else
System.out.println(" " +year+“年不是闰年。”);
[填空题]下列程序中需要清理动态分配的数组,划线处应有的语句是 【13】 。
#include<iostream, h>
class person int age, tall;
public:
person( ) age= 0; tall= 40; cout<<"A baby is born. "<<end1;
person(int i) age=i, tall=40, cout<<"A old person. "<<end1;
person(int i, int i) age = i; tall = j; cout <<" a old person with tall. "<<
end1;
~person( ) cout<<" person dead. "<<end 1;
void show( )
cout<<"age= "<<age<<" ,tall= "<<tall<<end1;
;
void main( ) person * ptr;
ptr = new person[3];
ptr[0]=person ( )
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3; i++)
ptr[i]. show( );
______
[单项选择]下面程序的结果是
#include
class A
{
int a;
public:
A( ):a (1){}
void showa( ){cout<<a;}
};
class B
{
int a;
public:
B( ):a (2){}
void showa( ){cout<<a;}
};
class C:public A, public B
{
int a;
public:
C( ):a (3){}
void showa( ){cout<<a;}
};
void main( )
{
C c;
c.showa( );
}
A. 1
B. 2
C. 3
D. 程序有错误
[填空题]下列程序中需要清理动态分配的数组,划线处应有的语句是______。
#include<iostream, h>
class person int age, tall;
public:
person( ) age= 0; tall= 40; cout<<"A baby is born. "<<end1;
person(int i) age=i, tall=40, cout<<"A old person. "<<end1;
person(int i, int i) age = i; tall = j; cout <<" a old person with tall. "<<
end1;
~person( ) cout<<" person dead. "<<end 1;
void show( )
cout<<"age= "<<age<<" ,tall= "<<tall<<end1;
;
void main( ) person * ptr;
ptr = new person[3];
ptr[0]=person ( )
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3; i++)
ptr[i]. show( );
______
[填空题]下列程序完成从文件读取文件显示的同时写入第二个文件,则在程序中划线部分应该出现的语句是 【14】 。
#include<iostream, h>
#include<fstream, h>
void main( ) fstream filel, file2;
char fnl [10], fn2[10], ch;
cout<<"输入源文件名";
cin>>fn1;
cout<<"输入目标文件名";
cin>>fn2;
file1. open(fn1, ios :: in);
______
while((ch=file1. get( )) ! =EOF)
cout<<ch;
file2. put(ch)
file1, close( )
file2, close( );
[填空题]下列程序完成从文件读取文件显示的同时写入第二个文件,则在程序中划线部分应该出现的语句是______。
#include<iostream.h>
#include(fstream.h)
void main( )
fstream filel,file2;
charfnl[10],fn2[10],ch;
cout<<“输入源文件名”;
cin>>fnl;
cout<<“输入目标文件名”;
cin>>fn2;
filel.open(fnl,ios::in);
while((ch;filel.get( ))!=EOF)
cout<<ch;
file2.put(ch);
filel.close( );
file2.close( );