niusouti.com

多选题import java.awt.*;    import java.applet.*;    public class ButtonDemo extends Applet{    public void init(){  Button pushButton=new Button(“ok”);  Button downButton=new Button(“Yess”);  add(pushButton);  add(downButton);  }  }  根据以上代码,下列解释正确的是()A该代码画了

题目
多选题
import java.awt.*;    import java.applet.*;    public class ButtonDemo extends Applet{    public void init(){  Button pushButton=new Button(“ok”);  Button downButton=new Button(“Yess”);  add(pushButton);  add(downButton);  }  }  根据以上代码,下列解释正确的是()
A

该代码画了一个按钮

B

Button(“ok”)创建了一个有显示“ok”的按钮

C

Button()是构造函数

D

按钮属于容器


相似考题
参考答案和解析
正确答案: B,D
解析: 暂无解析
更多“多选题import java.awt.*;    import java.applet.*;    public class ButtonDemo extends Applet{    public void init(){  Button pushButton=new Button(“ok”);  Button downButton=new Button(“Yess”);  add(pushButton);  add(downButton);  }  }  根据以上代码,下列解释正确的是()A该代码画了”相关问题
  • 第1题:

    下列程序在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

  • 第2题:

    下面程序代码,让用户输入想显示的.gif文件名,之后将这个图像文件加载到内存并显示。请勿改动原有代码,在下画线处填人适当浯句,将程序补充完整。

    import java.applet.*;

    import java.awt.*;

    import java.awt.event.*;

    public class test20_2 extends Applet implements ActionListener {

    Label promptLbl=new Label(“请输入欲显示的图像文件名:”);

    TextField inputTfd=new TextField20( );

    Button getlmageBtn=new Button(“显示图像”);

    Image mylmage;

    public void init( ) {

    add(promptLbl);

    add(inputTfd);

    add(getlmageBtn);

    inputTfd.setText(””);

    getlmageBtn.addActionListener(this);

    }

    public void paint(Graphics g) {

    if(mylmage!=null)

    g.______(mylmage,10,100,this);

    }

    public void actionPerformed(ActionEvent ae) {

    if(ae.getSource( )==_______) {

    String str=inputTfd.getText( ).trim( );

    if(!(str.substring(Math.max(0,str.length( )-4)).equals(".gif")))

    str=str.trim( )+".gif";

    mylmage=getlmage(getDocumentBase( ),str);

    repaint( );

    }

    }

    }


    正确答案:drawlmage getlmageBtn
    drawlmage getlmageBtn

  • 第3题:

    以下程序中,当用户单击“移动”按钮以后,就可以使用方向键控制屏幕上句子的移动,单击“停止”按钮,则句子不再随着方向键移动。运行结果如下图所示

    注意:请勿改动其他已有语句内容,仅在横线处填入适当语句。

    import java.applet.*;

    import java.awt.*;

    import java.awt.event.*;

    public class Example2_8 extends Applet implements KeyListener

    {

    public void keyTyped(KeyEvent e) {}

    public void keyReleased(KeyEvent e) {}

    Button button;

    Button stopButton;

    Label out;

    int x,y;

    public void _______ ()

    {

    button = new Button("移动");

    button.addActionListener(new AddMoveListener(this));

    stopButton = new Button("停止移动");

    stopButton.addActionListener(new RemoveListener(this));

    stopButton.setEnabled(false);

    out = new nabel("按下按钮以后我可以随方向键移动");

    add(button);

    add(stopButton);

    add (out);

    }

    public void start()

    {

    super, start ();

    }

    public void keyPressed(KeyEvent e)

    {

    x=out.getBounds().x;

    y=out.getBounds().y;

    if(e.getKeyCode()==KeyEvent.VK_UP)

    {

    y=y-2;

    if(y<=0) y=0;

    out. setLocation (x, y);

    }

    else if(e.getKeyCode()==KeyEvent.VK_DOWN)

    {

    y=y+2;

    if (y>=300) y=300;

    out. setLocation (x, y);

    }

    else if(e.getKeyCode()==KeyEvent.VK_LEFT)

    {

    x=x-2;

    if(x<=0) x=0;

    out. setLocation (x, y);

    }

    else if(e.getKeyCode()==KeyEvent.VK_RiGHT)

    {


    正确答案:init addKeyListener
    init addKeyListener 解析:本题考查知识点:小应用程序概念、Applet执行过程、JavaApplication和Applet。解题思路:Applet运行时,首先由浏览器调用init方法,该方法通知Applet已被加载,在这个方法中通常进行一些基本的初始化过程。Applet的基本方法还有start()、stop()、destroy()。类Example2_8实现了“KeyListener”监听器接口,就可以通过该监听器的方法监听键盘事件。需要填空的方法是初始化Applet程序,keyPressed()方法中专门处理方向键的事件。按下方向键以后,就会调用Label的setLocation()方法重新设置“out”所在的位置。当用户按下“移动”按钮以后,AddMoveListener为“移动按钮”添加了针对键盘的监听器。当用户按下“停止移动”按钮以后,RemoveListener从“移动”按钮中移出针对键盘事件的监听器。
    本题中start方法已经实现,另外两个方法分别用于Applet的停止和卸载,所以第一个空只能填“init”,用来为Applet实现初始化。
    由于本题是使用键盘来控制Label对象的移动,所以必须添加针对键盘的监听器,这样才能对键盘事’件做出反应,第二个空就是给“button”添加键盘事件监听器。

  • 第4题:

    下面程序构造了一个Swing Applet,在下画线处填入正确的代码。

    import javax.swing.*;

    import java.awt.*;

    public class SwingApplet extends ______ {

    JLabel 1=new JLabel("This is a Swing Applet.");

    public void init() {

    Container contentPane=getContentPane();

    contentPane.add(1);

    }

    }


    正确答案:Japplet
    Japplet

  • 第5题:

    import java.awt.*;  import java.applet.*;  public class ButtonDemo extends Applet{   public void init()  {    Button pushBotton=new Button(“ok”);    Button downBotton=new Button(“Yes”);     add(pushBotton);     add(downBotton);   } }  根据以上代码,下列结束正确的是()

    • A、该代码画了一个按钮
    • B、Button(“ok”)创建一个有显示”ok”的按钮
    • C、Button()是构造函数
    • D、按钮属于容器

    正确答案:B,C

  • 第6题:

    What will be the appearance of an applet with the following init() method?   public void init() {   add(new Button("hello"));  }  

    • A、Nothing appears in the applet.
    • B、A button will cover the whole area of the applet.
    • C、A button will appear in the top left corner of the applet.
    • D、A button will appear, centered in the top region of the applet.
    • E、A button will appear in the center of the applet.

    正确答案:D

  • 第7题:

    Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?()   import java.awt.*;   public class Q1e65 {   public static void main(String args[]) {   Window win = new Frame();   Button but = new Button("button");   // insert code fragment here  win.setSize(200, 200);   win.setVisible(true);   }   }  

    • A、win.setLayout(new BorderLayout()); win.add(but);
    • B、win.setLayout(new GridLayout(1, 1)); win.add(but);
    • C、win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);
    • D、win.add(but);
    • E、win.setLayout(new FlowLayout()); win.add(but);

    正确答案:A,B,C,D

  • 第8题:

    import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? () 

    • A、 The code will not compile.
    • B、 A Window will appear containing only a Button.
    • C、 An IllegalArgumentException is thrown at line 6.
    • D、 A Window button will appear but will not contain the Label, TextField, or Button.
    • E、 A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.
    • F、 A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.

    正确答案:B

  • 第9题:

    多选题
    import java.awt.*;    import java.applet.*;    public class ButtonDemo extends Applet{    public void init(){  Button pushButton=new Button(“ok”);  Button downButton=new Button(“Yess”);  add(pushButton);  add(downButton);  }  }  根据以上代码,下列解释正确的是()
    A

    该代码画了一个按钮

    B

    Button(“ok”)创建了一个有显示“ok”的按钮

    C

    Button()是构造函数

    D

    按钮属于容器


    正确答案: C,A
    解析: 暂无解析

  • 第10题:

    多选题
    import java.awt.*;  import java.applet.*;  public class ButtonDemo extends Applet{ public void init()  {   Button pushBotton=new Button("ok");    Button downBotton=new Button("Yes");    add(pushBotton);    add(downBotton); } }  根据以上代码,下列解释正确的是()。
    A

    该代码画了一个按钮

    B

    Button(ok)创建一个有显示ok的按钮

    C

    Button()是构造函数

    D

    按钮属于容器


    正确答案: D,A
    解析: 暂无解析

  • 第11题:

    单选题
    What will be the appearance of an applet with the following init() method?   public void init() {   add(new Button("hello"));  }
    A

    Nothing appears in the applet.

    B

    A button will cover the whole area of the applet.

    C

    A button will appear in the top left corner of the applet.

    D

    A button will appear, centered in the top region of the applet.

    E

    A button will appear in the center of the applet.


    正确答案: B
    解析: 暂无解析

  • 第12题:

    多选题
    import java.awt*;   public class X extends Frame (   public static void main(string args) (  X x = new X ();   X.pack();   x.setVisible(true);  )  public X () (   setlayout (new GridLayout (2,2));   Panel p1 = new panel();    Add(p1);    Button b1= new Button (“One”);    P1.add(b1);   Panel p2 = new panel();    Add(p2);   Button b2= new Button (“Two”);    P2.add(b2);    Button b3= new Button (“Three”);   add(b3);   Button b4= new Button (“Four”);   add(b4);   )   )   Which two statements are true? ()
    A

    All the buttons change height if the frame height is resized.

    B

    All the buttons change width if the Frame width is resized.

    C

    The size of the button labeled “One” is constant even if the Frame is resized.

    D

    Both width and height of the button labeled “Three” might change if the Frame is resized.


    正确答案: A,C
    解析: 暂无解析

  • 第13题:

    下列程序采用BorderLayout布局管理,选择正确的语句填入横线处,实现在North区域显示一个名字为“北方”的Button构件。 import java.awt.*; public class ex48 { public static void main(String[] args) { frame. frm = new Frame. ("北方"); frm.setLayout(new BorderLayout()); frm.setSize(200, 200); frm.setVisible(true); } }

    A.add("Nouth", new Button("北方"));

    B.frm.add("South", new Button("北方"));

    C.frm.add("Nouth", new Button("北方"));

    D.Frm.add("South", Button("北方"));


    正确答案:C

  • 第14题:

    下列Applet在窗口中放置2个Button,标签分别为“东”和“西”,在窗口中的位置与它们的名字相同。选择正确的语句填入横线处。 import java.awt.*; import java.applet.*; public class ex16 extends Applet { Button e, w; public void init() { e = new Button("东"); w = new Button("西"); add("East", e); add("West", w); } }

    A.setLayout(new BoxLayout());

    B.setLayout(new FlowLayout());

    C.setLayout(new BorderLayout());

    D.setLayout(new GridLayout());


    正确答案:C

  • 第15题:

    本题是一个Applet,功能是监听用对于文本域中文本的选择。页面中有一个文本域、一个“复制”按钮和一个文本框,选中文本域中部分文字后,单击按钮“复制”,所选文字将显示在文本框中。 import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class java3 extends Applet implements ActionL- istener { TextArea ta=new TextArea(5,30); TextField tf=new TextField(30); Button button=new Button("复制"); String text="AWT提供基本的GUl组件,\n"+" 具有可以扩展的超类,\n"+"它们的属性是继承的。\ n": public void init { setLayout(new FlowLayout(FlowLayout.left)); ta.setText(text); ta.setEditable(true); add(ta); add(button); add(tf); ta.addActionListener(this); } public void actionPerformed(ActionEvent e) { String S; s=ta.getSelectText; if(e.getSource= =button) tf.setText(s); } }


    正确答案:
    第1处:setLayout(new FlowLayout(FlowLayout.LEFT))
    第2处:button.addActionListener(this)
    一第3处:s=ta.getSelectedText
    【解析】第1处是设置构件的对齐方式为左对齐的且纵横间隔都是5个像素的布局管理器;第2处是为按钮注册监听器;第3处是在文本域ta中得到选中文本,将其赋给String类型的s。

  • 第16题:

    下列Applet用于显示提供它的主机的IP地址。请选择正确的语句填入横线处。 import java.awt.*; import java. awt. event.*; import java.applet.Applet; import java.net. *; public class ex23 extends Applet { public void init() { setLayout(new GridLayout(2, 1); Button btm = new Button("显示IP"); final Label 1 = new Label(" "); btn. addActionListener (new ActionListener ( ) { public void actionPerformed(ActionEvent ae) { try { URL ur1 = getCodeBase(); String strName = ur1.getHost(); ______ 1.setText (ia.toString()); } catch (Exception e) { e.printStackTrace (); } } }); add (btn); } }

    A.InetAddress ia = URL.getByName(strName);

    B.InetAddress ia = InetAddress.getByName(strName);

    C.InetAddress ia = new InetAddress.getByName(strName);

    D.InetAddress ia = InetAddress.getByName(ur1);


    正确答案:B

  • 第17题:

    import java.awt.*;  import java.applet.*;  public class ButtonDemo extends Applet{ public void init()  {   Button pushBotton=new Button("ok");    Button downBotton=new Button("Yes");    add(pushBotton);    add(downBotton); } }  根据以上代码,下列解释正确的是()。 

    • A、该代码画了一个按钮
    • B、Button("ok")创建一个有显示"ok"的按钮
    • C、Button()是构造函数
    • D、按钮属于容器

    正确答案:B,C

  • 第18题:

    import java.awt.*;    import java.applet.*;    public class ButtonDemo extends Applet{    public void init(){  Button pushButton=new Button(“ok”);  Button downButton=new Button(“Yess”);  add(pushButton);  add(downButton);  }  }  根据以上代码,下列解释正确的是() 

    • A、该代码画了一个按钮
    • B、Button(“ok”)创建了一个有显示“ok”的按钮
    • C、Button()是构造函数
    • D、按钮属于容器

    正确答案:B,C

  • 第19题:

    import java.awt.*;   public class X extends Frame {   public static void main (String args) {   X x = new X();   x.pack();   x.setVisible(true);   }  public X() {   setLayout (new BordrLayout());   Panel p = new Panel ();   add(p, BorderLayout.NORTH);   Button b = new Button (“North”);   p.add(b):   Button b = new Button (“South”);   add(b1, BorderLayout.SOUTH):   }   }   Which two statements are true?()

    • A、 The buttons labeled “North” and “South” will have the same width.
    • B、 The buttons labeled “North” and “South” will have the same height.
    • C、 The height of the button labeled “North” can very if the Frame is resized.
    • D、 The height of the button labeled “South” can very if the Frame is resized.
    • E、 The width of the button labeled “North” is constant even if the Frame is resized.
    • F、 The width of the button labeled “South” is constant even if the Frame is resized.

    正确答案:B,E

  • 第20题:

    import java.awt*;   public class X extends Frame (   public static void main(string args) (  X x = new X ();   X.pack();   x.setVisible(true);  )  public X () (   setlayout (new GridLayout (2,2));   Panel p1 = new panel();    Add(p1);    Button b1= new Button (“One”);    P1.add(b1);   Panel p2 = new panel();    Add(p2);   Button b2= new Button (“Two”);    P2.add(b2);    Button b3= new Button (“Three”);   add(b3);   Button b4= new Button (“Four”);   add(b4);   )   )   Which two statements are true? ()

    • A、 All the buttons change height if the frame height is resized.
    • B、 All the buttons change width if the Frame width is resized.
    • C、 The size of the button labeled “One” is constant even if the Frame is resized.
    • D、 Both width and height of the button labeled “Three” might change if the Frame is resized.

    正确答案:C,D

  • 第21题:

    多选题
    import java.awt.*;  import java.applet.*;  public class ButtonDemo extends Applet{   public void init()  {    Button pushBotton=new Button(“ok”);    Button downBotton=new Button(“Yes”);     add(pushBotton);     add(downBotton);   } }  根据以上代码,下列结束正确的是()
    A

    该代码画了一个按钮

    B

    Button(“ok”)创建一个有显示”ok”的按钮

    C

    Button()是构造函数

    D

    按钮属于容器


    正确答案: D,B
    解析: 暂无解析

  • 第22题:

    多选题
    import java.awt.*;   public class X extends Frame {   public static void main (String args) {   X x = new X();   x.pack();   x.setVisible(true);   }  public X() {   setLayout (new BordrLayout());   Panel p = new Panel ();   add(p, BorderLayout.NORTH);   Button b = new Button (“North”);   p.add(b):   Button b = new Button (“South”);   add(b1, BorderLayout.SOUTH):   }   }   Which two statements are true?()
    A

    The buttons labeled “North” and “South” will have the same width.

    B

    The buttons labeled “North” and “South” will have the same height.

    C

    The height of the button labeled “North” can very if the Frame is resized.

    D

    The height of the button labeled “South” can very if the Frame is resized.

    E

    The width of the button labeled “North” is constant even if the Frame is resized.

    F

    The width of the button labeled “South” is constant even if the Frame is resized.


    正确答案: E,F
    解析: 暂无解析

  • 第23题:

    多选题
    Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?()   import java.awt.*;   public class Q1e65 {   public static void main(String args[]) {   Window win = new Frame();   Button but = new Button("button");   // insert code fragment here  win.setSize(200, 200);   win.setVisible(true);   }   }
    A

    win.setLayout(new BorderLayout()); win.add(but);

    B

    win.setLayout(new GridLayout(1, 1)); win.add(but);

    C

    win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);

    D

    win.add(but);

    E

    win.setLayout(new FlowLayout()); win.add(but);


    正确答案: B,D
    解析: 暂无解析

  • 第24题:

    单选题
    import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? ()
    A

     The code will not compile.

    B

     A Window will appear containing only a Button.

    C

     An IllegalArgumentException is thrown at line 6.

    D

     A Window button will appear but will not contain the Label, TextField, or Button.

    E

     A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.

    F

     A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.


    正确答案: B
    解析: 暂无解析