更多“how many seats in the house of commons should a party hold at least in order to win th ”相关问题
  • 第1题:

    下面是一个Applet程序,其功能是实现一个计数器,每隔0.15秒计数器数值加1,数值动态变化,并且能够控制计数器的暂停和继续。要求通过使用Swing的构件建立图形用户界面。主要包括一个文本区域,用于显示计数器结果:两个按钮,一个使计数器暂停,一个使计数器继续工作。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。

    注意:不改动程序的结构,不得增行或删行。

    源程序文件代码清单如下。

    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.*;

    /*

    <applet code="ex19_3.class" width=800 height=400>

    </applet>

    */

    public class ex19_3 extends JApplet

    {

    private JTextField jtf=new JTextField(15);

    private JButton Hold=new JButton("Hold");

    private JButton resume=new JButton("Resume");

    private ex19_3th obj19_3th=new ex19_3th();

    class ex19_3th extends Thread

    {

    private int cnt=0;

    private boolean bIsHold=false;

    public ex19_3th() {start();}

    public void hold()

    {

    bIsHold=true;

    }

    public synchronized void fauxResume()

    {

    bIsHold=false;

    wait ();

    }

    public void run()

    {

    while (true)

    {

    try {

    sleep(150);

    synchronized(this)

    {

    while(bIsHold)

    notify();

    }

    }catch(InterruptedException ie)

    {

    System.err.println("Interrupted");

    }

    jtf.setText(cnt);

    }

    }

    }

    public void init()

    {

    Container cp=getContentPane();

    cp.setLayout(new FlowLayout());

    cp.add(jtf);

    Hold.addActionListener(

    new ActionListener()

    {

    public void actionPerformed(ActionEvent ae)

    {

    obj19_3th.hold ( );

    }

    });

    cp.add(Hold);

    resume.addActionListener

    (

    new ActionListener()

    {

    public void actionPerformed(ActionEvent e)

    {

    obj19_3th.fauxResume();

    }

    &n


    正确答案:notify() wait() jtf.setText.(Integer.toString(cnt++))
    notify() wait() jtf.setText.(Integer.toString(cnt++)) 解析:本题主要考查图形用户界面,Swing以及线程同步、共享、死锁相结合的综合应用。解题关键是熟悉wait()方法和notify()方法的含义,wait()必须被声明为synchronized,这样它才能拥有对象锁。fauxResume()把bIsHold标志设为false,并调用notify(),为了唤醒 synchronized子句中的wait(),notify()也必须被声明为synchronized,这样才能在调用notify()之前获得对象锁,然后该对象锁才能在wait()执行时被运用。本题中,第1和第2处,应该在bIsHold为true时调用wait(),而在 fauxResume()中调用notify();第3处,需要对 int类型做转换才能够作为String类型输出,并且要对计数器变量cnt做累加。程序运行结果如下。

  • 第2题:

    有如下类定义: class Point{ private: static int how_many; }; ___________how_many=0; 要初始化Point类的静态成员how_many,下画线处应填入的内容是( )。

    A.int

    B.static int

    C.int Point::

    D.static int Point::


    正确答案:C
    本题考查静态数据成员,静态数据成员可以初始化,但只能在类体外进行初始化,其一般形式为:数据类型类名::静态数据成员名=初值。所以本题答案为C。

  • 第3题:

    ______ it rain tomorrow moring, the loading ______.

    A.Should / will be postponed

    B.If / shall be postponed

    C.Should / would be postponed

    D.If / has to be postponed


    正确答案:C
    一旦明天早上下雨,装货将被延迟。

  • 第4题:

    有如下类定义: class Point{ private: static int how_many; }; ______how_many=0; 要初始化Point类的静态成员how_many,下划线处应填入的内容是

    A.int

    B.static int

    C.int Point: :

    D.static int Point


    正确答案:C
    解析:static int n;是定义静态全局变量,int point是定义类的。

  • 第5题:

    Examine the following options, Multicasting supports applications that communicate.()

    A. many - to - one

    B. one - to - one

    C. one - to - many

    D. many - to - many


    参考答案:C

  • 第6题:

    I was most surprised to hear Susan's marriage.

    A: very
    B: really
    C: more
    D: least

    答案:A
    解析:
    句意:苏珊结婚的消息让我很吃惊。四个选项中,B . really的意思是“真正地”;C. more的意思是“更多的”,在形容词前可表示比较级;D. least的意思是“最小的、最少的”,是littie的最高级;A. very的意思是“很、非常”,题目中画线部分most的用法很多,放在形容词前与定冠词连用表示形容词的最高级,如不加定冠词表示“很、非常”的意思,本题属于第二种情况,因此A选项符合题意。