网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

classFoo{

privateintx;

publicFoo(intx){this.x=x;}

publicvoidsetX(intx){this.x=x;}

publicintgetX(){returnx;}

}

publicclassGamma{

staticFoofooBar(Foofoo){

foo=newFoo(100);

returnfoo;

}

publicstaticvoidmain(String[]args){

Foofoo=newFoo(300);

System.out.print(foo.getX()+-);

FoofooFoo=fooBar(foo);

System.out.print(foo.getX()+-);

System.out.print(fooFoo.getX()+-);

foo=fooBar(fooFoo);

System.out.print(foo.getX()+-);

System.out.prmt(fooFoo.getX());

}

}

Whatistheoutputofthisprogram?()


参考答案

更多 “ classFoo{privateintx;publicFoo(intx){this.x=x;}publicvoidsetX(intx){this.x=x;}publicintgetX(){returnx;}}publicclassGamma{staticFoofooBar(Foofoo){foo=newFoo(100);returnfoo;}publicstaticvoidmain(String[]args){Foofoo=newFoo(300);System.out.print(foo.getX()+-);FoofooFoo=fooBar(foo);System.out.print(foo.getX()+-);System.out.print(fooFoo.getX()+-);foo=fooBar(fooFoo);System.out.print(foo.getX()+-);System.out.prmt(fooFoo.getX());}}Whatistheoutputofthisprogram?() ” 相关考题
考题 创建对象数组时,对数组的每一个元素都将调用一次构造函数,如果没有显式给出数组元素的初值,则调用缺省构造函数,下列程序涉及到对象数组的创建和单个对象的创建,其输出结果是( )。#includeusing namespace std;class Foo{public:Foo(int X){cout ’A”}Foo(){}};int main()Foo f[3],g(3);return 0;}

考题 创建对象数组时,对数组的每一个元素都将调用一次构造函数,如果没有显示给出数组元素的初值,则调用缺省构造函数。下列程序涉及对象数组的创建和单个对象的创建,其输出结果是______。include <iostream>using namespace std;class Foo{public:Foo(int x){cout<<'A';}Foo(){}};int main(){Foo f[3], g(3);return 0;}

考题 执行下面程序段,屏幕上将输出( )。 public class Test { private int x=10,y=20; public Test (int x,int y) { System.out.println (x+this.x); System.out.println (y+y); } public static void main (String[] args) { Testt= new Test(30,50); } }A.无输出B.20 40C.40 100D.40 70

考题 以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } }()A.1B.2C.3D.编译错误

考题 classFoo{publicstaticvoidmain(String[]args){intx=0;inty=4;for(intz=0;z〈3;z++,x++){if(x〉1++y〈10)y++;}System.out.println(y);}}结果是什么?() A.6B.7C.8D.10

考题 现有:classFoo{publicstaticvoidmain(String[]args){intx=O;inty=4;for(intz=0;z3;Z++;X++){if(x1++y10)y++;}System.out.println(y);}}结果是什么?() A.7B.8C.10D.12

考题 10.publicclassFooimplementsjava.io.Serializable{11.privateintx;12.publicintgetX(){returnx;}12.publicFoo(intx){this.x=x;}13.privatevoidwriteObject(ObjectOutputStreams)14.throwsIOException{15.//insertcodehere16.}17.}Whichcodefragment,insertedatline15,willallowFooobjectstobecorrectlyserializedanddeserialized?()A.s.writeInt(x);B.s.serialize(x);C.s.writeObject(x);D.s.defaultWriteObject();

考题 1.importjava.io.*;2.publicclassFooimplementsSerializable{3.publicintx,y;4.publicFoo(intx,inty){this.x=x;this.y=y;}5.6.privatevoidwriteObject(ObjectOutputStreams)7.throwsIOException{8.s.writeInt(x);s.writeInt(y)9.}10.11.privatevoidreadObject(ObjectInputStreams)12.throwsIOException,ClassNotFoundException{13.14.//insertcodehere15.16.}17.}Whichcode,insertedatline14,willallowthisclasstocorrectlyserializeand deserialize?()

考题 publicabstractclassShape{privateintx;privateinty;publicabstractvoiddraw();publicvoidsetAnchor(intx,inty){this.x=x;this.y=y;}}WhichtwoclassesusetheShapeclasscorrectly?() A.publicclassCircleimplementsShape{privateintradius;}B.publicabstractclassCircleextendsShape{privateintradius;}C.publicclassCircleextendsShape{privateintradius;publicvoiddraw();}D.publicabstractclassCircleimplementsShape{privateintradius;publicvoiddraw();}E.publicclassCircleextendsShape{privateintradius;publicvoiddraw(){/*codehere*/}}F.publicabstractclassCircleimplementsShape{privateintradius;publicvoiddraw(){/codehere*/}}