下列代码中,将引起编译错误的行是( )。 ① public class test{ ② public static void main(String args[]){ ③ float f=0.0; ④ f+=0; ⑤ } ⑥ }A.第2行B.第3行C.第4行D.第6行

下列代码中,将引起编译错误的行是( )。 ① public class test{ ② public static void main(String args[]){ ③ float f=0.0; ④ f+=0; ⑤ } ⑥ }

A.第2行

B.第3行

C.第4行

D.第6行


相关考题:

使用VC6打开考生文件夹下的工程test17_1,此工程包含一个源程序文件test17_1.唧,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:Vehicle messageCar messageVehicle message源程序文件test17_1.cpp 清单如下:include <iostream.h>class vehicle{int wheels;float weight;public:/***************** found *****************/void message(void){ cout<<"Vehicle message\n";}};class car:public vehicle{int passenger_load;public:/***************** found *****************/void message (void){cout>>"Car message\n";}};class truck:public vehicle{int passenger_load;float payload;public:int passengers(void){return passenger_load;}};void main(){vehicle * unicycle;unicycle=new vehicle;/***************** found *****************/unicycle.message()delete unicycle;unicycle=new car;unicycle->message();delete unicycle;unicycle=new truck;unicycle->message();delete unicycle;}

下列程序的运行结果是【 】。 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()}

下列程序编译时发现pb->f(10);语句出现错误,其原因是______。 include class Base { 下列程序编译时发现pb->f(10);语句出现错误,其原因是______。include<iostream.h>class Base{public:void f(int x){cout<<"Base:"<<x<<endl;)};class Derived:public Base{public:void f(char*str){cout<<"Derived:"<<str<<endl;}};void main(void){Derived*pd=new Derived;Pd->f(10);}

如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。include<iostream.h>class test{private:int hum;public:test(int);void show( );};test::test(int n){num=n;}test::show( ){cout<<num<<endl;}void main( ){test T(10):T.show( );}

阅读以下说明和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;}

对于下面代码说法正确的有 class A { public: A(int x) {} }; class B: public A{ public: B(){} }; int main() { B b; }A.编译错误B.编译正确,但是运行时没有输出信息C.在第三行代码后加上 A() = default; 就能编译通过D.在第二行代码后加上 A() {} 就能编译通过E.第七行改成 B():A(0){} 就能编译通过

在jdk中(也就是直接在MS-DOS界面中编译和运行Java源程序),如果源程序中有public类,()。A.可以有多个public类B.只能有一个public类C.public类必须是包含main方法的主类D.所有类必须都是public类

2、在jdk中(也就是直接在MS-DOS界面中编译和运行Java源程序),如果源程序中有public类,()。A.可以有多个public类B.只能有一个public类C.public类必须是包含main方法的主类D.所有类必须都是public类

给定以下代码,以下哪句是正确的? public class Test { String s; static class Inner { void testMethod() { s = "Hello world."; } } public static void main(String[] argv) { Inner i = new Inner(); i.testMethod(); System.out.println(s); } }A.编译通过,但是运行时刻出错,因为s没有被初始化B.无法编译,因为Test类里的String s不是static的C.编译通过,打印出Hello world.D.无法编译,因为Inner不能像这样在main中使用