更多"应在下列程序画线处填入的正确语句是 ( )。 #include <"的相关试题:
[单项选择]在下列程序画线处填入的正确语句是( )。
#include <iostream>
using namespace std;
class Base
public:
void fun( )
cout<<"Base::fun",<<end1;
;
class Derived:public Base
void fun( )
______________ //显式调用基类的函数fun( )
cout<<"Derived::fun" <<end1;
;
A. fun();
B. Base.fun();
C. Base::fun();
D. Base->fun();
[单项选择]下面程序有注释的语句中,错误的语句是( )。
#include <iostream>
using namespace std;
class A
int a;
public:
void show A( )cout<<"this is A!";
;
class B:public A
int b;
public:
void show B( )cout<< "this is B!";
;
void main( )
A ia,*piA;
B ib,*piB;
piA=ia; //第一个测试语句
piA=&ib; //第二个测试语句
piA->showA( ); //第三个测试语句
piA->showB( ); //第四个测试语句
A. 第一个测试语句
B. 第二个测试语句
C. 第三个测试语句
D. 第四个测试语句
[单项选择]下列程序中画线处应填入的语句是 class Base { public: void fun( ){cout<<"Base of fun"<<end1;} }; class Derived:public Base { void fun( ) { ______//显示基类的成员函数fun cout<<"Derived of fun"<<end1; } };
A. fun( );
B. Basfun( );
C. Base: :fun( );
D. Base->fun( );
[单项选择]为完成下面的程序,应在划线处填入的语句是( )。 #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(int :Base({}
B. Derived(){}
C. voidDerived(int :Base(0){}
D. Derived(int {Base(;}
[填空题]bar为一JSerollBar组件,阅读下面程序段,请在程序中的画线处填入正确的语句使程序能够正确运行。
…
public WellAdjusted( )
{
super("Well Adjusted");
setSize(350,100);
bar.addAdjustmentListener(this);
value.setHorizontalAlignment(SwingConstants.CENTER);
value.setEditable(false);
JPanel pane=new JPane( );
pane.setLayout(new BorderLayout( ));
pane.add(value,"Center"):
pane.add(bar,"South");
setContentPane(pane);
}
public void adjustmentValueChanged(AdjustmentEvent evt)
{
【12】
if(source==bar)
{
int newValue bar.getValue( );
value.setText(""+newValue);
}
repaint( );
}
…
[单项选择]下列程序从标准输入设备—键盘诗篇一个字符,然后再输出到屏幕。要想完成此功能,画线处应该填入的语句为( )。
impoajava.io.*;
publicclassTest
publicstaticvoidmain(Stringargs[])
charch;
try
______,
System.out.println(Ch);
catch(IOExceptione)
e.printStackTrace( );
A. ch=System.in.read();
B. ch=(char)System.in.read();
C. ch=(char)System.in.readln();
D. ch=(int)System.in.read();
[单项选择]为了支持压栈线程与弹栈线程之间的交互与同步,在程序的下画线处依次填入的语句是______。
public class IntStack
private int idx=0;
private int[]data=new int[8];
public______void push(int i)
data[idx]=i;
idx++;
A. svnchronized() notify()
B. synchronized this.wait()
C. svnchronized this.notify()
D. Serializable sleep()
[单项选择]有以下程序:
#include <iostream>
#include <math>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a,double b)
x=a;
y=b;
friend double distance(point a,point b) ;
;
double distance(point a,point b)
return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main ( )
point pl(1,2);
point p2 (5, 2);
cout<<distance (pl,p2) <<end1;
return 0;
程序运行后的输出结果是()
A. 1
B. 5
C. 4
D. 6
[填空题]
已知下列程序的输出结果是42, 请将画线处缺失的部分补充完整。
#include<iostream>
using namespace std;
class Foo
int value;
public:
Foo( ): value(0) {}
void setValue(int value)
{ 【10】 =value; //给Foo的数据成员value赋值}
void print( ) { cout<<value;}
};
int main( )
{
Foo f;
f.setValue(42);
f.print( );
return 0;
[单项选择]应在下面程序下划线中填写的正确的语句是( )。
#include <iostream>
using namespace std;
class A
public:
void test( )cout<< "this is A!";
;
class B:public A
void test( )
______ //显示调用基类函数test( )
cout<< "this is B!";
;
void main( )
A. A) :test()
B. C) :test()
[填空题]请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
该程序的功能是求以命令行参数指定的整数的阶乘。完成程序并运行,所得结果为:
5的阶乘是120.0
源程序:
//程序的功能是求以命令行参数指定的整数的阶乘。
public class Java_3
public static void main(String[] args)
String num;
if(args.length>0)Bum= (1) ;
else num="5":
int input=Integer.parseInt( (2) );
double result=factorial(input);
System.out.println(input+"的阶乘是"+result);
public static double factorial(int x)
if(x<0)return 0.0;
double fact=1.0:
while(x>1)
fact (3) * x;
x=x-1;
return fact;
[填空题]请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
[题目要求]
请完善程序,并进行调试,程序运行结果为:
aa=512
bb=-167
ff=593.94
dd=5.938839067268372
源程序:
import java.io.*;
public class Java_1
public static void main(String args[])
char a=’p’:
byte b1=6;
int i=400;
long b=345L;
float f=98.99f;
double d=4.7788;
(1) aa=a+i;
long bb=b-aa;
(2) if=b1*f;
double dd=ff/aa+d;
System.out.println("aa="+aa);
System.out.println("bb="+bb);
System.out.println("ff="+ff);
System.out.println("dd="+dd);