30.以下程序的界面有一个文本区text,一个按钮button。程序运行时,单击按钮,则?
将文本区中的内容输出到out,其中out为BufferWriter类的一个对象。?
public void actionPerformed(ActionEvente){?
String s;?
if(e._______== button){?
try {?
out. _______(text.getText(),0,(text.getText()).length());?
out. flush();?
text.setText(null);?
System.exit(0);?
} catch(IOException exp)?
{text.setText("文件定出错! \n"); System.exit(-1);}?
}?
}?
31.数据库连接方法connectByJdbcOdbc()按给定的数据库URL、用户名和密码连接数?
据库,如果连接成功,方法返回连接对象,连接不成功,则返回空。?
public static Connection connectByJdbcOdbc(Stringurl, String usemame, String password){?
Connection con = null;?
try {Class. _______("sun.jdbc.odbc.JdbcOdbcDriver");?
} catch (Exception e) {?
e.printStackTrace();?
return null;?
}?
try {?
con =_______.getConnection(url, usemame,password);?
catch (SQLException e) {?
e.printStackTrace();?
return null;?
}?
return con;?
}?
}?
五、程序分析题(本大题共5小题,每小题4分,共20分)?
32.阅读下列程序,请写出该程序的输出结果。?
class Test32a {?
String name; int age; long number;?
Test32a(long number, String name,int age) {?
System.out.println("Name:" name);?
System. out. println("Age: " age);?
System.out.println("Tel: " number);?
}?
}?
class Test32b extends Test32a {?
Test32b(long number, String name,intage,boolean b) {?
super(number, name,age); System.out.println("Married:" b);?
}
}?
public class Test32 {?
public static void main(String args[]) {?
Test32b abe=newTest32b(4747,"Tony",29,true);?
}
}?