Whatwillbetheresultofattemptingtocompileandrunthefollowingprogram?()publicclassQ28fd{publicstaticvoidmain(Stringargs[]){intcounter=0;l1:for(inti=10;i0;i--){l2:intj=0;while(j10){if(ji)breakl2;if(i==j){counter++;continuel1;}}counter--;}System.out.println(counter);}}A.Theprogramwillfailtocompile.B.Theprogramwillnotterminatenormally.C.Theprogramwillwrite10tothestandardoutput.D.Theprogramwillwrite0tothestandardoutput.E.Theprogramwillwrite9tothestandardoutput.

Whatwillbetheresultofattemptingtocompileandrunthefollowingprogram?()publicclassQ28fd{publicstaticvoidmain(Stringargs[]){intcounter=0;l1:for(inti=10;i<0;i--){l2:intj=0;while(j<10){if(j>i)breakl2;if(i==j){counter++;continuel1;}}counter--;}System.out.println(counter);}}

A.Theprogramwillfailtocompile.

B.Theprogramwillnotterminatenormally.

C.Theprogramwillwrite10tothestandardoutput.

D.Theprogramwillwrite0tothestandardoutput.

E.Theprogramwillwrite9tothestandardoutput.


相关考题:

以下程序输出结果为______。 include using namespace std; class TestClass 1 { publi 以下程序输出结果为______。include<iostream>using namespace std;class TestClass 1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;}:class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i:}void dispb(){dispa();cout<<"x2="<<x2<<end1;}private:int x2:}:int main(){TestClass2 b(2):b.dispb();return 0;}

在下面的类定义中,this指针的用途是______。 include class Sample { int x,y; publi 在下面的类定义中,this指针的用途是______。include<iostream.h>class Sample{int x,y;public:Sample(int i,int j){x=i;y=j;}void assign(Sample sa);};void Sample::assign(Sample p){if(this!=p){x=p.x;y=p.y;}}

下列程序中横线处正确的语句是()。includeusing namespace std;class TestClass{publi 下列程序中横线处正确的语句是( )。 #include<iostream> using namespace std; class TestClass { public: void fun(){cout<<"TestClass::fun"<<end1;} }; class TestClass1:public TestClass { void fun() { ______//显示调用基类的函数 fun() cout<<"TestClass1::fun"<<end1; } };A.fun();B.TestClass.fun()C.TestClass::fun();D.TestClass->fun();

若有如下程序:includeusing namespace std;int s=O;class sample{static int n;publi 若有如下程序: #include<iostream> using namespace std; int s=O; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<S<<end1; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3

下面程序的结果为 include int c; class A { private: int a; static int b; publi 下面程序的结果为#include<iostream.h>int c;class A{private:int a;static int b;public:A( ) {a=0;c=0;}void seta( ) {a++;}void setb( ) {b++;}void setc( ) {c++;}void display( ) {cout < < a < < " " < < b < < " " < < c;}};int A: :b=0;void main( ){A a1,a2;a1.seta( ) ;a1.setb( ) ;al .setc( ) ;a2.seta( ) ;a2.setb( ) ;a2.setc( ) ;a2.display( ) ;}A.1 2 1B.1 2 2C.1 1 2D.2 2 2

有以下程序:include using namespace std;int s=0;class sample{ static int n;publi 有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;A.2B.5C.7D.3

下面程序的结果是 include class test{private: int num; publi 下面程序的结果是 #include<iostream.h> class test{ private: int num; public: test( ); int getint( ) {return num;} ~test( );}; test::test( ) { num=0;} test::~test( ) { cout<<"Destructor is active"<<endl;} voidA.Exiting main Destructor is active Destructor is active Destructor is activeB.Exiting main Destructor is active Destructoris activeC.Exiting main Destructoris activeD.Exiting main

若有如下程序:includeusing namespace std;int s=0;class sample{static int n;publi 若有如下程序: #include<iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { S+=n; } }; int sample::n=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是( )。A.2B.5C.7D.3