n(str); System.out.println("Name:"+name); System.out.println("Birth Year:"+birthYear); System.out.println("Flower:"+flower); } } class PineTree extends Tree { public boolean coniferous = true; PineTree(String n, boolean f, int y, boolean c){super(n, f, y);coniferous = c; } public void printTree(String str){ super, printTree(str); System.out.println("Coniferous:" + coniferous); } } class Test32 { public static void main(String []args){ Tree fOb = new Tree("May Flower", true, 1980); PineTree sOb = new PineTree("Pine", false, 2000, true); fOb.printTree(" fOb:"); sOb.printTree("sOb:"); } } 33.阅读下列程序,请写出该程序的输出结果。 class Test33 {
5
全国 2009 年 10 月自学考试 Java 语言程序设计(一)试题
static void s (int b[ ], int k) { int i, j, t; for(i = 1;i< k; i++) { for(t = b[i], j = i-1; j >= 0 &;&; t < b[j]; j--) b[j+l] = b[j]; b[j+ 1 ] = t; } } public static void main(String []args){ int i, a[] = {6, 12, 7, 11, 5 }; s(a, 5); for(i = 0;i< a.length; i++) System.out.print(a[i]+" "); System. out. Println(); } } 34.阅读下列程序,请写出
该程序的功能。 import java.applet.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Test34 extends Applet implements ActionListener { JTextField text;int r; JPanel panel; public void paint(Graphics g){ Graphics gc = panel.getGraphics(); gc.clearRect(0,0, panel.getWidth(), panel.getHeight()); gc.setColor(Color.red); gc.fillOval(10, 10, r, r); } public void init() { text = new JTextField(10); panel = new JPanel();
setSize(200, 100); setLayout(new GridLayout(2,1)); add(text); add(panel); text.addActionListener(this); } public void actionPerformed(ActionEve