下列程序段的输出结果是______。 public class Test{ int a,b; Test( ){ a=100; b=200; } Test(int x,int y){ a=X; b=y; } public static void main(String args[ ]){ Test Obj1=new Test(12,45); System.out.println("a="+Obj1.a+"b="+Obj1.B); Test Obj2=new Test( ); System.out.print

题目

下列程序段的输出结果是______。 public class Test{ int a,b; Test( ){ a=100; b=200; } Test(int x,int y){ a=X; b=y; } public static void main(String args[ ]){ Test Obj1=new Test(12,45); System.out.println("a="+Obj1.a+"b="+Obj1.B); Test Obj2=new Test( ); System.out.println("a="+Obj1.a+"b="+Obj1.B); } }

A.a=100 b=200 a=12 b=45

B.a=12 b=45 a=100 b=200

C.a=12 b=200 a=100 b=45

D.a=100 b=45 a=12 b=200


相似考题
更多“下列程序段的输出结果是______。public class Test{int a,b;Test( ){a=100;b=200;}Test(int x,int ”相关问题
  • 第1题:

    已知程序中已经定义了函数test,其原型是int test (int,int,int);,则下列重载形式中正确的是( )。

    A.char test(int, int, int);

    B.double test (int,int,double);

    C.int test(int ,int, int=0);

    D.float test(int,int,float=3.5F);


    正确答案:B

  • 第2题:

    如下程序编译时发生错误,错误的原因是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( );

    }


    正确答案:void test::show( ){coutnumendl;}
    void test::show( ){coutnumendl;} 解析:show成员函数的声明和实现不一致,即实现部分应有void修饰符,这样才能编译通过。

  • 第3题:

    00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    A

  • 第4题:

    下列程序的输出结果是______。 include using namespace std; class Test( public: Te

    下列程序的输出结果是______。 #include<iostream> using namespace std; class Test( public: Test() {cnt++;} ~Test() {cnt--;} static int Count(){return cnt;} private: static int cnt; }; int Test::cnt=0; int main() { cout<<Test::Count()<<""; Test t1,t2; Test*pT3=new Test; Test*pT4=new Test; cout<<Test::Count()<<""; delete pT4; delete pT3; cout<<Test::Count()<<end1; return 0; }

    A.024

    B.042

    C.420

    D.240


    正确答案:B
    解析:此题考查的是类的构造函数与析构函数的调用。语句 coutTcst::Count()"";;输出“0”,因为static型变量cnt的默认值是0;“T Test t1,t2;Test*pT3=new Test;Test*pT4=new Test;”调用4次类的构造函数,使得cnt的值增加到4,并输出4;然后delete pT4;delete pT3;调用两次析构函数,cnt的值变为2,并输出2。

  • 第5题:

    以下标识符哪些是合法的?哪些是Java的关键字? miles, Test, a++, --a, 4#R, $4, #44, apps,class, public, int, x, y, min value, 成绩, radius,最大值max。


    TwoUsers

  • 第6题:

    下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    C.循环执行1次