问题描述:
[填空题] 将下列的程序补充完整。 import java.applet.Applet; import java.awt.Graphics; public class Applet2 extends Applet { public void paint(Graphics gap) { in i=678; gap.drawstring(Integer.【 】 (i),20,60); } }
下面是一个Applet程序,其功能是有2个按钮,分别为First和Second,以及一个Labe1构件。要求点击First时则能在Labe1中显示出Command:First,而点击Second时则能显示出Command: Second,要求只能使用重载一次actionPerformed( )方法。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code=ex20_3.class width=800 height=400> </applet> */ public class ex20_3extends Applet implements ActionListener private String str="Ok"; private Label 1; private Button btn; public void init() setLayout(null);1=new Label(str); 1.reshape(10,10,100,30);add(1);btn=new Button("First"); btn.reshape(10,50,60,20); 1.addAcUonljstener(this);add(btn); btn=new Button("Second"); btn.reshape(10,100,60,20); btn.setActionCommand("First"); btn.addAc“OnListener(this); add(btn); public void actionPerformed(ActionEvent ae) str="Command:"+ae.getActionColllInttnd( ); btn.setText(str);
对于下面一段代码的描述中,正确的是______。public class ex36{ public static void run main(String[] args) throws Excepion { method(); } static void method() throws Exception try { System.out.println("test"); } finally { System.out.println ("finally"); } } }
在Java中,3.14156D表示的是【 】数。
阅读下面代码段:public class Test{ public static void main(String args[]){char ch;switch(ch){ case’a’:System.out.print("abc");break; case’b’:System.out.print("ab"); case’c’:System.out.print("c");break; default:System.out.print("abc");} }}不输出"abc"的ch值是( )
Java的体系结构中,最下层是移植接口,最上一层是Java应用程序和 【6】 。
点评难度:
参考答案:
问题解析:
试题分享: