参考答案和解析
参考答案:C
更多“Wuxi(0 the east of South China. ”相关问题
  • 第1题:

    classParent{Stringone,two;

    classParent{

    Stringone,two;

    publicParent(Stringa,Stringb){

    one=a;

    two=b;}

    publicvoidprint(){System.out.println(one);}}

    publicclassChildextendsParent{

    publicChild(Stringa,Stringb){

    super(a,b);

    }

    publicvoidprint(){

    System.out.println(one+"to"+two);

    }

    publicstaticvoidmain(Stringarg[]){

    Parentp=newParent("south","north");

    Parentt=newChild("east","west");

    p.print();

    t.print();

    }

    }

    Whichofthefollowingiscorrect?()


    参考答案:E
    这个题目涉及继承时的多态性问题,在前面的问题中已经有讲述,要注意的是语句t.print();在运行时t实际指向的是一个Child对象,即java在运行时决定变量的实际类型,而在编译时t是一个Parent对象,因此,如果子类Child中有父类中没有的方法,例如printAll(),那么不能使用t.printAll()。

  • 第2题:

    请将下列程序的空白处补充完整。

    Importjava.awt.*;

    PublicclassEll_4

    {

    Publicstaticvoidmain(Stringargs[])

    {

    Framef=newFrame(“BorderLayout”);

    fiadd(“North”,newbuRon(“North”));

    f.add(“East”,newbutton(“East”));

    f.add(“West”,newbutton(“West”));

    f.add(“South”,tf);

    f.setSize(200,200)

    fipack();

    fisetVisible(true);

    }

    }


    正确答案:TextField if=llew TextField("Text");
    TextField if=llew TextField("Text"); 解析: 本题考查java中常用组件的创建。由题可知,创建的是3个按键和1个文本框,tf为该文本框。

  • 第3题:

    表达“东西南北”四个方位时,英语的习惯一般是______?

    A.north, east, south and west

    B.east, west, north and south

    C.north, south, east and west

    D.east, south, west and north


    north, east, south and west;north, south, east and west

  • 第4题:

    importjava.awt.*;publicclassXextendsFrame{publicstaticvoidmain(Stringargs){Xx=newX();x.pack();x.setVisible(true);}publicX(){setLayout(newBordrLayout());Panelp=newPanel();add(p,BorderLayout.NORTH);Buttonb=newButton(North”);p.add(b):Buttonb=newButton(South”);add(b1,BorderLayout.SOUTH):}}Whichtwostatementsaretrue?()

    A.Thebuttonslabeled“North”and“South”willhavethesamewidth.

    B.Thebuttonslabeled“North”and“South”willhavethesameheight.

    C.Theheightofthebuttonlabeled“North”canveryiftheFrameisresized.

    D.Theheightofthebuttonlabeled“South”canveryiftheFrameisresized.

    E.Thewidthofthebuttonlabeled“North”isconstanteveniftheFrameisresized.

    F.Thewidthofthebuttonlabeled“South”isconstanteveniftheFrameisresized.


    参考答案:B, E

  • 第5题:

    下列程序在Frame中设定BorderLayout布局管理器,选择正确的语句填入程序的横线处。 import java.awt.*; public class ex43 extends Frame { public static void main(String[] args) { ex43 bj = new ex43("BorderLayout"); ______ obj.add("North", new Button("North")); obj.add("South", new Button("Sourth")); obj.add("East", new Button ("East")); obj.add("West", new Button ("West")); obj. add ("Center", new Button ( "Center" ) ); obj.pack(); obj. setVisible (true); } public ex43(String str) { super (str); } }

    A.obj.setLayout(new BorderLayout());

    B.setLayout(new Borderkayout());

    C.setLayout(BorderLayout());

    D.obj.setLayout(BorderLayout());


    正确答案:A