首页/ 题库 / [单选题]下列程序段的输出结果是______。 p的答案

下列程序段的输出结果是______。 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); } }

单选题
2022-01-04 19:32
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
查看答案

正确答案
B

试题解析
解析: 本程序中Test类有两个构造方法,亦即使用了重载技术。不带参数的构造方法对类的实例变量进行特定数值的赋值,而带参数的构造方法根据参数对类的实例变量进行赋值。

标签:
感兴趣题目
编译和运行下列程序,请选择正确的输出结果______。 public class ex31 { private void test() { System.out.println(6 + 6 + "(Result)"); } public static void main(String[] args) { new ex31().test(); } }
下列程序的输出结果是______。 main() { int a=2; do{ printf("%d ",a-=2); }while(!(--a)); }
下列程序段的输出结果是______。int x=3;do{ printf("%d",x-=2);}while (!(--x));
以下程序段的输出结果是______。 int x=5; do {ptintf("%2d ",x--); }while(!x);
下列程序的输出结果是______。 int b=2; int func(int*a) {b+=*a;return(b); } main() { int a=2,res=2; res+=func(&b); printf("%d ,res); }
有以下程序 main() { int a,b,d=25; a=d/10%9;b=a&&(-1) printf("%d,%d ",a,b); } 程序运行后的输出结果是______。
在下列程序的划线处应填入的语句是 ( ) class Person { private int a; } public class Man extends Person { public int b public static void main(String arg[]) { Person P=new Person(); Man t=new Man(); int i; ______ } }
下列程序的输出结果是______。 #include<stdio.h> main () { int a=2,c=5; printf("a=%%d,b=%%d ",a,c); }
有以下程序 #include<stdio.h> main() { int a=5,b=lt; t=(a<<2)|b;printf("%d ",t); } 程序运行后的输出结果是______。
下列程序的输出结果是______。main(){ int a=12,b=12;printf("%d%d ",--a,++b);
下列程序的输出结果是______。 main() { unsigned short a=65536;int b; printf("%d ",b:a); }
在下列程序的划线处应填入的语句是 class Pemon { pnvate int a; } public class Man extends Person { public int b; public static void main(String arg[ ] ) { Person p = new Person( ); Man t = new Man( ); int i; ________ } }
相关题目
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
若类A和类B的定义如下: class A { public: int i,j; void get(); }; class B:A{ int i, j; protected; int k; public: void make(); }; void B: :make()(k=i*j;} 则其中 ______ 是非法的表达式。
下面程序的输出结果是______。 main() { int a=6,b=3; printf("%d " b=(a/b,a%b)); }
下面程序段的输出结果是 ______。 int X=20, y=20; cout<<x- -<<" , "<< - -y;
设int a=l,b=2;,执行语句printf("%d",a>=ba:b);后的输出结果是__________。
设int a=8,b=2,c=3;,执行语句a%=b+c;printf("%d",a);后的输出结果是__________。
下列程序的输出结果是_______。 main() { int a=0,b=0,c=0; if(++a>0||++b>0)++c; printf(" a=%d,b=%d,c=%d",a,b,c) ; }
下列程序运行后的输出结果是______。 main() { int a=2,b=-1,c=2; if(a<b) if(b<0) c=0; else c++; printf ("%d ",c);
有以下程序: main() { unsigped int a; int b=-1; a=b; printf("% u", a); } 程序运行后的输出结果是______。
有以下程序: main() { int a=666, b=888; printf("% d ", a, b); } 程序运行后的输出结果是______。
下列程序段的输出结果是______。 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); } }
有如下类定义: class Test { int x_,y_; public: Test ():a_(0) ,b_(0) {} Test(int a,int b=0) :a_(a),b_(b){} }; 若执行语句 Test x(2) ,y[3],*z[4]; 则Test类的构造函数被调用的次数是( )。
以下程序段的输出结果是 ______。 int a=5,b=4,c=6,d; cout<<(d=a>b?(a>c?a:c):b);
执行下列程序段之后,变量b的值为______。 public class Test9 { public static void main(String[] args) { int i=12; int j=24; boolean b1=true; boolean b=(j%i== 0)&&(!b1) ||(j/i!=2); System.out.println(b); } }
能将程序补充完整的选项是 class Person { private int a; public int change(int m){return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]) { Person p=new Person(); Teacher t=new Teacher(); int i; ______ } }
能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }
有如下程序 float fun (int x,int y){return(x+y);} main() { int a=2,b=5,c=8; printf("%3.Of ",fun((int)fun(a+c,B) ,(a-C) )) } 程序运行后的输出结果为_______。
执行下列程序之后,变量n的值为______。 public class Test{ public static void main(String[ ]args){ int y=2; int z=3; int n=4; n=n+-y*z/n; System.out.println(n); } }
下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int[ ]a=new int[11]; int[ ]p=new int[4]; int k=5; for(int i=1;i<=10;i++) a[i]=i; for(int i=1;i<=3;i++) p[i]=a[i*i]; for(int i=1;i<=3;i++) k=k+p[i]*2; System.out.println(k); } }
若类A和类B的定义如下: class A { public: int i,j; void get(); }; class B:A{ int i, j; protected; int k; public: void make(); }; void B: :make()(k=i*j;} 则其中 ______ 是非法的表达式。
广告位招租WX:84302438

免费的网站请分享给朋友吧