阅读下面程序
import javax.swing.JOptionPane;
public class BreakLabelTest{
public static void main (String args[]){
String utput=" ";
stop:{
for(int row=1;row<10;row++){
for(int column=1;column<=5;column++){
if(row=5)
break stop;
output+=" * ";
}
output+=" \n ";
}
output+="\nLoops terminated normally";
}
JOptionPane.showMessageDialog(
null,output,"用一个标志测试break语句”,
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
程序运行结果是
A.窗口中有5行* * * * *
B.窗口中有5行* * * *
C.窗口中有4行* * * * *
D.窗口中有6行* * * * *
第1题:
下面程序的结果是 #include<iostream.h> class A { int a; public: A( ):a(1){} void showa( ){cout<<a;} }; class B { int a; public: B( ) :a(2) {}
A.1
B.2
C.3
D.程序有错误
第2题:
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }
A.CBA
B.ABC
C.ACB
D.BCA
第3题:
第4题:
阅读下面程序:
include <iostream.h>
template <class T>
class TAdd
{
private:
T x, y;
public:
TAdd(T a, T b)
{
x=a;
y=b;
}
T add()
{
return x +y;
}
};
void main( )
{
TAdd<int>a(5,6);
TAdd<double>b(2.4,5.8);
cout<<"s1 ="<<A. add()<<",";
cout<<"s2="<<B, add()<<end1;
}
写出该程序的运行结果:【 】。
第5题:
下面程序的结果是 ______。 #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 file
B.new file new file new file
C.编译出错
D.open file new file save file
第6题:
阅读下面的程序, 写出运行后输出的结果。 #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B :public A { public: B(){cout<<"B";} }; void main() { B b1; }