阅读下面程序: import javax.swing.JOptionPane; public class Comparison { public static void main (Stringargs[]){ String firstNumber, //用户输入第1个数据变量 secondNumber, //用户输入第2个数据变量 result; //输出结果变量 mtnumberl, //用于比较的第1个数 number2; //用于比较的第2个数 //用户输入第1个数据的字符串 firstNumber=JOptionPane.showlnputDialog(“输入第1个整数:”) //用户输入第2个数据的字符串 secondNumber=JOptionPane。showlnputDialog(“输入第2个整数:”); //将字符串转换为整数类型 number1=Integer.parseInt(firstNumber); number2=Integer.parseInt(secondNumber); //初始化结果变量 _________________________; //比较两个数据 if(number1=number2) result+=numberl+"="+number2; if(number1 !=number2) resun+=numberl+"!="+number2; if(number1<number2) result=result+"\n"+number1+"<"+nunlber2; if(number1>number2) result=result+"\n"+numberl+">"+number2; if(numberl<=number2) result二reSUlt+”h1”+numberl+”仁”+number2; if(number1>=number2) result=result+"\n"+number1+">="+number2; //显示结果 JOpdonPane.showMessageDialog(null,rcsult, "比较结果", JOpdonPane.INFORMATION_MESSAGE; System,exIT(0); } } 为使程序能正确运行并得到合理的输出结果,初始化结果变量语句(下划线处)应是 ( )。A.result=""B.resnlt=nullC.resun=number1D.result=number2

阅读下面程序: import javax.swing.JOptionPane; public class Comparison { public static void main (Stringargs[]){ String firstNumber, //用户输入第1个数据变量 secondNumber, //用户输入第2个数据变量 result; //输出结果变量 mtnumberl, //用于比较的第1个数 number2; //用于比较的第2个数 //用户输入第1个数据的字符串 firstNumber=JOptionPane.showlnputDialog(“输入第1个整数:”) //用户输入第2个数据的字符串 secondNumber=JOptionPane。showlnputDialog(“输入第2个整数:”); //将字符串转换为整数类型 number1=Integer.parseInt(firstNumber); number2=Integer.parseInt(secondNumber); //初始化结果变量 _________________________; //比较两个数据 if(number1=number2) result+=numberl+"="+number2; if(number1 !=number2) resun+=numberl+"!="+number2; if(number1<number2) result=result+"\n"+number1+"<"+nunlber2; if(number1>number2) result=result+"\n"+numberl+">"+number2; if(numberl<=number2) result二reSUlt+”h1”+numberl+”仁”+number2; if(number1>=number2) result=result+"\n"+number1+">="+number2; //显示结果 JOpdonPane.showMessageDialog(null,rcsult, "比较结果", JOpdonPane.INFORMATION_MESSAGE; System,exIT(0); } } 为使程序能正确运行并得到合理的输出结果,初始化结果变量语句(下划线处)应是 ( )。

A.result=""

B.resnlt=null

C.resun=number1

D.result=number2


相关考题:

有如下程序:includeusing namespace std;Class Base{public:Base(){cout 有如下程序: #include<iostream.h> using namespace std; Class Base { public: Base(){cout<<“BB”;f();} void{(){cout<<“BF”;} }; class Derived:public Base { public: Derived(){cout<<“DD”;} void f(){cout<<“Df”;) }; int mainA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va 下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}

下面程序运行时输出结果为【】。 include include class Rect { public: Rec 下面程序运行时输出结果为【 】。include<iostream.h>include<malloc.h>class Rect{public:Rect(int1,int w)(length=1;width=w;)void Print(){cout<<"Area:"<<length *width<<endl;)void *operator new(size-t size){return malloc(size);}void operator delete(void *p){free(p)private:int length,width;};void main(){Rect*p;p=new Rect(5,4);p->Print();delete p;}

在下面程序中,括号里应填()。 include using namespace std; class A { public: void 在下面程序中,括号里应填( )。 #include <iostream> using namespace std; class A { public: void fun( ) { cout << "Hello" << endl; } }; class B:: public A { void fun( ) { ( ) //调用基类的函数fun( ) tout << "HI" << endl; } };A.fun()B.A. fun()C.A::fun()D.A-fun(

将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}

请写出下面的输出:class B{public:virtual void Print(void){printf(“B::Print\n”);}virtual void Reprint(void){printf(“B:Reprint\n”);}void Algo(void){Print();Reprint();}};class D : public B{public:virtual void Print(void){printf(“D::Print\n”);}};void main(){B *p = new D();p-Print();p-Algo();}

下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class 下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=c; p->fun (); p=b; p->fun (); p=d; p->fun(); }A.new file open file save fileB.new file new file new fileC.编译出错D.open file new file save file

阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。【Java代码】interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}

阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。【C++代码】#include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}

阅读下面的程序, 写出运行后输出的结果。 #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B :public A { public: B(){cout<<"B";} }; void main() { B b1; }