ǰλãҳ > JAVA语言程序设计期末考试题及答案【创意版?doc - 百度文库
Ʒĵ C. smallButton.addActionListener(myListener); D. smallButton.addItem(myListener);
1. д룬˵γĹܡ import java.io.*; public class Test{
public static void main( String [] argv) { try {
BufferedReader is =
new BufferedReader( new InputStreamReader(System.in));
String inputLine;
While ((inputLine = is.readLine ())!= null) {
System.out.println(inputLine);
} is.close();
}catch (IOException e) {
System.out.println(\
} } }
𰸣ȡ룬ʾĻϣֱΪΪֹ 2 гдȷн class test {
public static void main (String [] args ){
int x=9, y; if (x>=0)
if (x>0) y=1; else y=0;
else y=-1;
System.out.println(y);
}
} 𰸣1
.
Ʒĵ 3 дȷн public class Father{
int a=100; public void miner(){
a--;
}
public static void main(String[] args){
Father x = new Father(); Son y = new Son(); System.out.println(y.a); System.out.println( y.getA()); y.miner();
System.out.println(y.a); System.out.println(y.getA());
}
}
class Son extends Father{
int a = 0; public void plus(){ a++; }
public int getA() { return super.a; } } 𰸣
0 100 0 99 .
1. JavaԵص㡣
ԣJavaC++C++ĵط JavaԵȫ ֲʽ ִУ
.
Ʒĵ ׳ԣJavaṩԶջƣ쳣ƣϸͼ ƽ̨ԣ ȫ ߳ ̬
2. AWT¼ģ͡
AWT¼ģͲ˵ import java.awt.event.*;
1. ʵֶӦ¼Ľӿ
class MyFirstFrame extends Frame implements ActionListener {...}
2ȷ¼Ľӿʽ
public void actionPerformed ( ActionEvent event) {}
3. MyFirstFrame ʵֽӿActionListenerез 4. ע.
Ϊ˰MyFirstFrameעΪť¼MyFirstFrame Ĺ캯£ cancelButton.addActionListener(this); okButton.addActionListener(this);
3. JavaУһ̣߳
1ʵRunnableӿ
class TestThread implements Runnable { public void run() { } } 2̳Threadʵ
class TestThread extends Thread { TestThread(String name) { super(name); start(); }
public void run() {} }
.
Ʒĵ
.
92ƪĵ