首页/ 题库 / [单选题]下面程序段的输出结果为 public c的答案

下面程序段的输出结果为 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=”+Obj 1.a+” b=”+Obj 1.b); Test Obj2=new Test(); System.out.println(”a=”+Obj 2.a+” b=”+Obj 2.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类有两个构造方法,即使用了方法重载技术。不带参数的构造方法对类的实例变量进行特定数值的赋值,而带参数的构造方法根据参数对类的实例变量进行赋值。TestObj1=newTest(12,45)语句调用的是Test(intx,inty),而TestObj2=newTest()调用的是Test(),注意根据参数个数来区分。

标签:
感兴趣题目
下列程序的输出结果是 ( ) class Derao { void test() { Systeme.out.print("NO");} void test (int i) {System.out.print(a);} void test(int a,int b) {System.out.print(a+b);} } class Test { public static void main(String args[]) { Demo de=new Demo(); de.test(); de.test5.; de.test(6,8); } }
下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.test(5); de.test(6,8); } }
阅读下面程序 public class Test2 { public static void main(String[] args) { int a=10,b=4.c=20,d=6; System.out.println(a++*b+c*--d); } } 程序运行的结果是
下列语句输出结果为( )。 public class test { public static void main (String args[ ]) { int a=23,b=8,c=5; int e=a%(b%c); System.out.println(e); } }
下面程序段的输出结果是( )。 public class Test { public static void main ( String[] args) { int result=0; for ( int i=1;i<=5;i++) { if ( i%2==0 ) continue; result + =i; } System. out. println ("result is " + result ); } }
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int n=10,result=0; for (int i=1;i<=n;i++) result+=i; System.out.println("result is"+result); } }
下列语句输出结果为( )。 public class test { public static void main (String args[]) { int x=10,y=9; boolean b=true; System.out.println(x<y||!b); } }
有如下程序: #inClude<iostream> using namespaCe std; Class test{ private: int a; publiC: test( ){Cout<<”ConstruCtor”<<endl;} test(int A.{Cout<<a<<endl;} test(Const test&_test){ a=test.a: Cout<<”Copy ConstruCtor”<<endl: } test( ){Cout<<”destruCtor”<<endl;} }; int main( ){ test A(3); return 0; } 执行这个程序的输出结果是( )。
下面程序段的输出结果为 package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
有如下程序: #include<iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;
下面程序段的输出结果是 public class Test{ public static void main(String args[]){ int n=5,sum=0; while(n>0){ sum+=n; --n; } System.out.println("sum is"+sum); } }
下面程序段的输出结果是 public class Test{ public static void main(String args[]){ int n=5,sum=O; while(n>0){ sum+=n; --n; } System.out.println("sum is "+Sum); } }
相关题目
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int n=10; do { System.out.println("n is"+n); }while(--n>10); } }
Test.java程序代码如下: public class Test{ public static void main(String[] args){ System.out.println(args[1]); } } 以上程序编译后用java Test 2 3 4 5运行的输出结果是什么? ( )
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int sum=0; for ( int i=0;i<=100; i++) sum+=i; System. out. println ("sum="+sum); } }
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }
下面程序段的输出结果为 package test; public class Class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println("x"+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
有如下类定义: class Test { public: Test(){a=0;C=0;t //① int f(int A) const{this->a=a;} //② static int g( ){return a;} //③ void h(int B) {Test::b=b;}; //④ private: int a; static int b; const int c; }; int Test::b=0: 在标注号码的行中,能被正确编译的是
有如下类定义: class Test { public: Test(){a=0;c=0;} //① int f(int a)const {this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b=b;}; //④ private: int a; static int b; const int c; }; int Test::b=0; 在标注号码的行中,能被正确编译的是
有如下类定义: class Test { public: Test(){a=0;c=0} //① int f(int a)const{this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b;}; //④ private: int a; static int b; const int C; }; int Test::b=0; 在标注号码的行中,能被正确编译的是( )。
下面程序段的输出结果为 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 bjl=new Test(12,45); System.out.println("a="+objl.a+" b="+Objl.B); Test Obj2=new Test(); System.out.println("a="+Obj2.a+" b="+Obj2.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("="+Obja+" b="+ObjB) ; } }
下面程序段的输出结果为 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=”+Obj 1.a+” b=”+Obj 1.b); Test Obj2=new Test(); System.out.println(”a=”+Obj 2.a+” b=”+Obj 2.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 public static void main(String args[]) { int a=1,b=2,c,d; c=a++;d=--b; System.out.print("c="+c);System.out.println("d="+d);
有如下程序 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 = "+ObB) ; Test Obj1 = new Test(); System.out.println("a = "Obj1.a+" b = "+Obj1.B) ; } } 程序的运行结果为( )。
下面程序段的输出结果为( )。 public class Test { public static void main(String args[]) { booleana,b,C; a=(3<5): b=(a= =true); System.out.println("a="+a+"b="+b); c=(b= =false); System.out.println("b="+b+"c="+c); } }
下面程序段的输出结果为( )。 public class Test { public static void main(String args[]) { booleana,b,C; a=(3<5): b=(a= =true); System.out.println("a="+a+"b="+b); c=(b= =false); System.out.println("b="+b+"c="+c); } }
下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+B); c=(b==false); System.out.println("b="+b+"c="+C); } }
3下面程序段的输出结果为( )。 mblic class Test public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+b); c=(b=false); System.out.println("b="+b+"c="+c); } }
有如下类定义: 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类的构造函数被调用的次数是( )。
下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.printin( "a="+a+"b="+b) ; c-(b==false); System.out.println(b="+b+"e="+c) ; } }
广告位招租WX:84302438

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