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

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

有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z(); } Z() { Z aliasl=this; Z alias2=this; synchronized(aliasl) { try{ alias2.walt(); System.out.println("DONE WAITING"); } catch(InterruptedException e) { System.out.println("INTERR UPTED"); } catch (Exception e) { System.out.println("OTHER EXCEPTION"); } finally{ System.out.println("FINALLY"); } } System.out.println("ALL DONE"); } }

A.应用程序编译正常,但是不打印任何数据

B.应用程序编译正常,并打印数据“DONE WAITING”

C.应用程序编译正常,并打印数据“FINALLY”

D.应用程序编译正常,并打印数据“ALL DONE”


参考答案

更多 “ 有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z(); } Z() { Z aliasl=this; Z alias2=this; synchronized(aliasl) { try{ alias2.walt(); System.out.println("DONE WAITING"); } catch(InterruptedException e) { System.out.println("INTERR UPTED"); } catch (Exception e) { System.out.println("OTHER EXCEPTION"); } finally{ System.out.println("FINALLY"); } } System.out.println("ALL DONE"); } }A.应用程序编译正常,但是不打印任何数据B.应用程序编译正常,并打印数据“DONE WAITING”C.应用程序编译正常,并打印数据“FINALLY”D.应用程序编译正常,并打印数据“ALL DONE” ” 相关考题
考题 有如下程序:#includeiostreamusing namespace std;class Music{public:void setTitle(char*str){strcpy(title,str);}protected:char type[10];private:char title[20];};class Jazz:public Music{public:void set(char*str){strcpy(type,”Jazz”); //①strcpy(title,str); //②}};下列叙述中正确的是A.程序编译正确B.程序编译时语句①出错C.程序编译时语句②出错D.程序编译时语句①和②都出错

考题 有如下程序: #inCludeiostream using namespaCe std; Class MusiC{ publiC: void setTitle(Char*str){strCpy(title,str);} proteCted: Char type[10]; private: Char title[20]; Class Jazz:publiC MusiC{ publiC: void set(Char*str){ strCpy(type,”Jazz’);//① strCpy(title,str);//② } }; 下列叙述中正确的是( )。A.程序编译正确B.程序编译时语句①出错C.程序编译时语句②出错D.程序编译时语句①和②都出错

考题 有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z (); } Z() { Z alias1 = this; Z alias2 = this; synchronized(alias1) { try { alias2.wait(); System.out.println("DONE WAITING"); } catch (InterruptedException e) { System.out.println( "INTERRUPTED"); } catch (Exception e) { System.out.println("OTHER EXCEPTION"); } finally { System.out.println ("FINALLY"); } } System.out.println("ALL DONE"); } }A.应用程序编译正常,但是不打印任何数据B.应用程序编译正常,并打印数据“DONE WAITING”C.应用程序编译正常,并打印数据“FINALLY”D.应用程序编译正常,并打印数据“ALL DONE”

考题 阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。 【说明】 以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。 【Java代码】 interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}

考题 为使下列代码正常运行,应该在下划线处填入的选项是()abstract class Person { private String name; public Person (String n) { name = n; } public ____________String get Description(); public String getName() { return name; } }A.privateB.abstractC.finalD.static

考题 为使下列代码正常运行,应该在下划线处填入的选项是() abstract class Person { public Person (String n) { name = n; } public ____________String getDescription(); public String getName() { return name; } private String name; }A.privateB.abstractC.finalD.static

考题 对于下面代码说法正确的有 class A { public: A(int x) {} }; class B: public A{ public: B(){} }; int main() { B b; }A.编译错误B.编译正确,但是运行时没有输出信息C.在第三行代码后加上 A() = default; 就能编译通过D.在第二行代码后加上 A() {} 就能编译通过E.第七行改成 B():A(0){} 就能编译通过

考题 3、为使下列代码正常运行,应该在下划线处填入的选项是() abstract class Person { public Person (String n) { name = n; } public ____________String getDescription(); public String getName() { return name; } private String name; }A.privateB.abstractC.finalD.static

考题 下列说法中,不正确的是()A.一个接口interface源程序经过编译后,得到的文件的扩展名一定是.class#B.一个java源程序编译通过后,得到的文件的扩展名一定是.class#C.一个java源程序可以有多个 class类定义,源文件的名字与public class的类名相同,且只能有一个public类,如果没有public类,源文件的名字必须与第一个类的类名相同,扩展名必须是.java#D.一个java源程序可以包含多个class类