有如下程序: Private Sub Commandl_Click( ) Dim i As Integer For i=1 To 2 DS Next i End Sub Sub DS( ) Dim x As Integer,m As String Static y,n X=X + 1 y=y + 1 m=m &"*”:n=n&"#" Print x,y,m,n End Sub 程序运行后,输出的结果是A.1 1 * #B.1 1 * #C.1 1 * # 1 1 * # 1 2 * #D.1 1 * #

题目

有如下程序: Private Sub Commandl_Click( ) Dim i As Integer For i=1 To 2 DS Next i End Sub Sub DS( ) Dim x As Integer,m As String Static y,n X=X + 1 y=y + 1 m=m &"*”:n=n&"#" Print x,y,m,n End Sub 程序运行后,输出的结果是

A.1 1 * #

B.1 1 * #

C.1 1 * # 1 1 * # 1 2 * #

D.1 1 * # 1 1 * ## 1 2 * ##


相似考题
更多“有如下程序: Private Sub Commandl_Click( ) Dim i As Integer For i=1 To 2 DS ”相关问题
  • 第1题:

    有如下程序:include using namespace std;class sample{private: int x, y;public: s

    有如下程序: #include <iostream> using namespace std; class sample { private: int x, y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"displ"<<end1; } void disp() const { cout<<"disp2"<<end1; } }; int main () { const sample a(i,2); a.disp (); return 0; } 该程序运行后的输出结果是( )。

    A.disp1

    B.disp2

    C.disp1 disp2

    D.程序编译时出错


    正确答案:B
    解析:C++中,在定义常对象时必须进行初始化,而且不能被更新。如果将一个对象说明为常对象,则通过该对象只能调用它的常成员函数。题中,对象a被定义成类sample的常对象,所以通过对象a只能调用其常成员函数disp()。所以程序最后输出disp2。

  • 第2题:

    以下程序段有()处错误。include using namespaces std;class Sample{private: int n;p

    以下程序段有( )处错误。 #include <iostream> using namespaces std; class Sample { private: int n; public: Sample (int i} { n=i; } void setvalue(int i) { n=i; } void display() { cout<<"n="<<n<<end1; } }; int main ( ) { const Sample a(lO); a. setvalue (5)'; a.display(); return 0; }

    A.1

    B.2

    C.3

    D.4


    正确答案:B
    解析:本题考查常对象的掌握。本程序中有两个错误:①第1处错误是“a.setvalue(5);”语句,由于对象a为常对象,所以对象a的私有数据成员n不能被更新。②第2处错误是语句“a.display();”。由于对象a为常对象,所以通过对象a只能调用它的成员函数,而成员函数display()不是常成员函数。

  • 第3题:

    设有如下程序

    public class test {

    public static void main(String args[]) {

    Integer intObj=Integer.valueOf(args[args.length-1]);

    int i = intObj.intValue();

    if(args.length >1、

    System.out.println(i);

    if(args.length >0)

    System.out.println(i -1、;

    else

    System.out.println(i - 2、;

    }

    }

    运行程序,输入如下命令:

    java test 2

    则输出为:

    A. test

    B. test -1

    C. 0

    D. 1

    E. 2


    正确答案:D

  • 第4题:

    有下列程序:includeusing namespace std;class TestClass{private:int x,y;public:Te

    有下列程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"printl"<<endl; } vo

    A.print1

    B.print2

    C.pfint1 print2

    D.程序编译时出错


    正确答案:B
    解析: 由主函数main入手,定义TestClass型的常对象a,然后调用对象a中的成员函数print()。因为在C++中,如果一个对象被声明为常对象,则不能调用该对象中的非const型的成员函数。所以,这里调用的是对象中的const型成员函数“void print ()const”,输出为print2。

  • 第5题:

    有如下程序: #inClude<iostream> using namespaCe std; ClaSS A{ publiC: A(int i){x=i;} void dispa( ){Cout<<x<<’,’;} private: int x; }; Class B:publiC A{ publiC: B(int i):A(i+10){x=i;} vold dispb( ){dispa( );Cout<<x<<endl;} private: int x; }; int main( )} B b(2); b.dispb( ); return 0; } 执行这个程序的输出结果是( )。

    A.10,2

    B.12,10

    C.12,2

    D.2,2


    正确答案:C
    本题考查派生类的构造函数和基类的构造函数。本题中类B继承类A,定义了·个类B的对象并初始化b(2),此时会执行类B的构造函数,执行的结果是继承类A中的私有成员赋值了12,给类B自身的数据成员x赋值了2,执行b.dispb后,输出类A的私有成员x,输出类B自身的数据成员,所以答案为C。

  • 第6题:

    8、下列程序中,哪一行语句有错误 。 1 PROGRAM P01 2 INTEGER:: I,S=0 3 DO I=10,1,-2 4 I=I*I 5 S=S+I 6 ENDDO 7 END PROGRAM

    A.2

    B.3

    C.4

    D.7


    C