如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
2022Sunjava认证考试真题答案Sunjava认证考试真题答案SUN认证是给网络设计界建立的一套认证标准,Sun公司推出了Java以及Solaris技术认证方案。以下是我整理的关于Sunjava认证考试真题答案,希望大家仔细阅读!1.Whatgetsprintedwhenthefollowingprogramiscompiledandrun?classTest{publicstaticvoidmain(Stringargs[]){inti;do{i++;}while(i<0);System.out.println(i);}}Select1correctanswer:A.Theprogramdoesnotcompileasiisnotinitialized.B.Theprogramcompilesbutdoesnotrun.C.Theprogramcompilesandrunsbutdoesnotprintanything.D.Theprogramprints0.E.Theprogramprints1.答案:A:假如没有初始化便运用基本变量类型,会导致编译时异样,程序不能编译。2.Whatgetsprintedwhenthefollowingprogramiscompiledandrun?publicclassXYZ{publicstaticvoidmain(Stringargs[]){inti,j,k;for(i=0;i<3;i++){for(j=1;j<4;j++){for(k=2;k<5;k++){if((i==j)&&(j==k))System.out.println(i);}}}}}Select1correctanswer:A.0B.1C.2D.3E.4答案:C3.Giventhefollowingcode:classBase{}publicclassMyCastextendsBase{staticbooleanb1=false;staticinti=-1;staticdoubled=10.1;publicstaticvoidmain(Stringargv[]){MyCastm=newMyCast();Baseb=newBase();//Here}}Whichofthefollowing,ifedatthecomment//Herewillallowthecodetocompileandrunwithouterror?Select2correctanswers:A.b=m;B.m=b;C.d=i;D.b1=i;解析:A从子类型到父类型的转换是扩展引用转换,不须要在运行时实行特别的动作,不会在运行时抛出异样。B从超类型到子类型的转换是收缩引用转换,须要在运行时执行测试,以查明实际的引用值是否是新类型的合法值.假如不是,则会抛出ClassCascException。在这里,b本身不是MyCast类型的值,因此会导致运行时异样。C从int到double的转换是扩展基本转换,基本类型之间的扩展转换恒久不会导致运行时异样。但从int或long到float,或者是从long到double都可能导致精度丢失。D不允许进行int和boolean之间的.类型转换答案:A、C4.Giventhefollowingclasseswhichofthefollowingwillcompilewithouterror?interfaceIFace{}classCFaceimplementsIFace{}classBase{}publicclassObRefextendsBase{publicstaticvoidmain(Stringargv[]){ObRefob=newObRef();Baseb=newBase();Objecto1=newObject();IFaceo2=newCFace();}}Select3correctanswers:A.o1=o2;B.b=ob;C.ob=b;D.o1=b;解析:A任何对象都可以赋给Object类型的对象,正确B子类赋给超类是扩展引用转换,可以进行C收缩引用转换,错误D扩展引用转换,可以进行答案ABD5.Whatistheresultofcompilingandrunningthefollowingcode?1publicclassTest{2staticinttotal=10;3publicstaticvoidmain(Stringargs[]){4newTest();5}6publicTest(){7
冷霜****魔王
实名认证
内容提供者
最近下载