单选题class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项()?A 23B 21C 22D 编译错误
单选题
class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项()?
A
23
B
21
C
22
D
编译错误
参考解析
解析:
暂无解析
相关考题:
下面程序的运行结果为【 】。class A} public:int num;A(int i){num=i;}A(A a){num=++a.num;}void print(){cout<<num;}};void main(){A a(1),b(a);a.print();b.print();}
使用VC6打开考生文件夹下的工程test33_1,此工程包含一个源程序文件test33_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果为:Number=1,2,3sum=16源程序文件test33_1.cpp清单如下;include <iostream.h>class Num{public:/***************** found *****************/void Num(int a,int b, int c);void PrintNumber();void PrintSum();private:int x,y,z;static int sum;};/***************** found *****************/int sum=10;Num::Num(int a,int b, int c){x=a;y=b;z=c;sum=sum+x+y+c;}void Num::PrintNumber(){cout<<"Number="<<x<<","<<y<<","<<z<<end1;}void Num::PrintSum(){cout<<"sum="<<sum<<end1;}void main( ){Num m(1,2,3),*n;n=m;m. PrintNumber();/***************** found *****************/n. PrintSum();}
若有如下程序:public class Test {public static void main (String[] args) {int x=20;if (x>10) System.out.print(x-=5);if (x>5) System.out.print(x--);}}则程序运行后的输出结果是【 】。
下面程序的运行结果为includeclass A{int num;public:A(int i){num=i;}A(A a) 下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int i){num=i;} A(A a) { num = a.num+ +;} void print( ) {cout << num;} }; void main( 0 { A a (1),b (a) ; a.print( ); b.A.11B.12C.21D.22
下面程序的运行结果为 include class A {int num; public: A(int) {num=i;} A(A public:A(int) {num=i;}A(A a) {hum=a. num++;}void print( ) {cout < < num;}};void main( ){A a(1) ,b(a) ;a. print( ) ;b. print( ) ;}A.11B.12C.21D.22
下列程序的运行结果是【 】。 include class test { private: int num; public: tes 下列程序的运行结果是【 】。include <iostream. h>class test{private:int num;public:test()int TEST() {return num+100;}~test()};test::test(){num=0;}test::~test(){cout<<"Destructor is active"<<endl;}void main(){test x[3]cout<<x[1]. TEST()<<endl;}
classTestReference{publicstaticvoidmain(String[]args){intx=2;TestReferencetr=newTestReference();System.out.print(x);tr.change(x);System.out.print(x);}publicvoidchange(intnum){num=num+1;}}程序运行后的输出是哪项()?A.23B.21C.22D.编译错误
程序:classTestReference{publicstaticvoidmain(String[]args){intx=2;TestReferencetr=newTestReference();System.out.print(x);tr.change(x);System.out.print(x);}publicvoidchange(intnum){num=num+1;}}程序运行后的输出是哪项?()A.23B.21C.22D.编译错误
下列程序执行后的结果为______。 public class exl2 { public static void main(string[] args) { int n=4; int x=0; do{ System.out.print(n); }while (x++<n--); } }A.12B.432C.43D.4
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
下面程序的运行结果为includeclass A{ int num;public: A(int){num=i;} A(ABm){num 下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int){num=i;} A(ABm){num=a.num++;} void print(){cout<<num;} }; void main() { Aa(1),b(a); a.print(); b.print(); }A.11B.12C.21D.22
下面程序段的输出结果为 package test; public 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 Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过
以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误
程序: class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项?() A、 23B、 21C、 22D、 编译错误
class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项()? A、 23B、 21C、 22D、 编译错误
public class Pass { public static void main(String [1 args) { int x 5; Pass p = new Pass(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuff x = “+ x++); } } What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 doStuffx = 6 main x = 6D、 doStuffx = 5 main x = 5E、 doStuffx = 5 main x = 6F、 doStuffx = 6 main x = 5
class Passer { static final int x = 5; public static void main(String [] args) { new Passer().go(x); System.out.print(x); } void go(int x) { System.out.print(++x); } } 结果是什么?() A、55B、56C、65D、66
class Beverage { Beverage() { System.out.print("beverage "); } } class Beer extends Beverage { public static void main(String [] args) { Beer b = new Beer(14); } public int Beer(int x) { this(); System.out.print("beer1 "); } public Beer() { System.out.print("beer2 "); } } 结果是什么?() A、beer1 beverageB、beer2 beverageC、beverage beer1D、编译失败
public class TestApp{ public static void main(String[] args){ try{ int i = 0; int j = 1 / i; String myname=null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } catch(Exception e){ System.out.print(“3”); } } } 上述程序运行后的输出是哪项?()A、 3B、 2C、 231D、 32
现有 class Beverage { Beverage () { System.out.print ("beverage "); } } class Beer extends Beverage { public static void main{string [] args) { Beer b = new Beer (14) ; } public int Beer(int x) { this () ; System.out.print ("beerl") ; } public Beer() { System.out.print("beer2 "); } } 结果是什么?() A、beerl beverageB、beer2 beverageC、beverage beer2 beerlD、编译失败
单选题现有 class Beverage { Beverage () { System.out.print ("beverage "); } } class Beer extends Beverage { public static void main{string [] args) { Beer b = new Beer (14) ; } public int Beer(int x) { this () ; System.out.print ("beerl") ; } public Beer() { System.out.print("beer2 "); } } 结果是什么?()Abeerl beverageBbeer2 beverageCbeverage beer2 beerlD编译失败
单选题public class Pass { public static void main(String [1 args) { int x 5; Pass p = new Pass(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuff x = “+ x++); } } What is the result?()A Compilation fails.B An exception is thrown at runtime.C doStuffx = 6 main x = 6D doStuffx = 5 main x = 5E doStuffx = 5 main x = 6F doStuffx = 6 main x = 5
单选题class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项()?A 23B 21C 22D 编译错误
单选题class Passer { static final int x = 5; public static void main(String [] args) { new Passer().go(x); System.out.print(x); } void go(int x) { System.out.print(++x); } } 结果是什么?()A55B56C65D66
单选题class Beverage { Beverage() { System.out.print("beverage "); } } class Beer extends Beverage { public static void main(String [] args) { Beer b = new Beer(14); } public int Beer(int x) { this(); System.out.print("beer1 "); } public Beer() { System.out.print("beer2 "); } } 结果是什么?()Abeer1 beverageBbeer2 beverageCbeverage beer1D编译失败
单选题程序: class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项?()A 23B 21C 22D 编译错误
单选题public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()ACompilation fails.BAn exception is thrown at runtime.CdoStuff x=6 main x=6DdoStuff x=5 main x=5EdoStuff x=5 main x=6FdoStuff x=6 main x=5
单选题class Top { static int x = 1; public Top(int y) { x *= 3; } } class Middle extends Top { public Middle() { x += 1; } public static void main(String [] args) { Middle m = new Middle(); System.out.println(x); } } 结果为:()A1B2C3D编译失败