System.out.println(ar[i]);
}
}
答案:Mine是MineBase的子类,要么实现MineBase的抽象方法amethod(),要么把自己声明为abstract。
答案:用来管理UI界面对象布局的。
常见的有FlowLayout、GridLayout等。
1)The ActionListener interface has no corresponding Adapter class
2) The processing of an event listener requires a try/catch block
3) If multiple listeners are added to a component only events for the last listener added will be processed
4) If multiple listeners are added to acomponent the events will be processed for all but with no guarantee in the order
答案:3
1) A class may extend only one other class and implement only one interface
2) interfaces are the Java approach to addressing its lack of multiple inheritance but require implementing classes to create the functionality of the Interfaces.
3) All of the variables in an interface are implicitly static and final
4) All of the methods in an interface are implicitly abstract
答案:2、3、4
interface Iface{}
Class Cface implements Iface{}
Class Base{};
Public class ObRef extends Base{
ObRef ob=new ObRef();
Base b=new Base();
Object o1=new Object();
Iface o2=new Cface();
}
1)o1=o2;
2)b=ob;
3)ob=b;
4)o1=b;
答案:1、2、4
1) At the root of the collection hierarchy is a class called Collection
2) The collection interface contains a method called enumerator
3) The interator method returns an instance of the Vector class
4) The set interface is designed for unique elements
答案:4
public String statement(){
String =””;
for(int i=0;i<500;i++)
s+=Item[i];
return s;
}
答案:String的连接操作(+=)会产生很多对象,性能不好
public String statement(){
StringBuffer buffer = new StringBuffer();
for(int i=0;i<500;i++)
buffer.append(Item[i].toString());
return buffer.toString();
}
try{
Statement sm = con.createStatement();
ResultSet rs=sm.execQuery(“SQL字符串”);
int i=rs.getInt(1);
//其它语句
rs.close();
sm.close();
}catch(SQLException e){
处理程序
}
答案:数据库的释放应该在finnaly块中
Statement sm = null;
ResultSet rs = null;
try{
m = con.createStatement();
rs=sm.execQuery(“SQL字符串”);
int i=rs.getInt(1);
//其它语句
}catch(SQLException e){
处理程序
}finally{
try{
if(rs != null && !rs.isClosed()){
rs.close();
}
}catch(Exception ex){
rs = null;
}
try{
if(sm != null){
sm.close();
}
}catch(Exception ex){
sm = null;
}
}
那么java bbb.class 会运行成功吗?如果不能运行话,什么原因?
答案:能够正确运行。
class Base{
private void amethod (int iBase){
System.out.println(“Base.amethod”);
}
}
class Over extends Base{
public static void main(String vrgv[]){
Over o=new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver){
System.out.println(“Over.amethod”);
}
}
1)Compile time error complaining that Base amethod is private
2)Runtime error complaining that Ba