ception类,那么哪一个方法声明适合以下的方法体代码?( )B(4分)
{
success = connect();
if (success = = 1) {
throw new TimedOutException();
}
}
5. 如果一个对象仅仅声明实现了cloneable接口,但是不声明clone方法,外部能够调用其clone方法吗?( )B(4分)
6 .写出下列程序所完成的功能:(15分)
import java.io.* ;
public class Reverse
{
public static void main(String args[ ])
{
int i , n =10 ;
int a[ ] = new int[10];
for ( i = 0 ; i < n ; i ++ )
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
a[i] = Integer.parseInt(br.readLine( ));
} catch ( IOException e ) { } ;
for ( i = n – 1 ; i >= 0 ; i — )
System.out.print(a[i]+” “);
System.out.println( );
}
}
从标准输入(即键盘)读入10个整数存入整型数组a中,然后逆序输出这10个整数。
7. Java编程,打印昨天的当前时刻。(15分)
public class YesterdayCurrent{
public void main(String[] args){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
System.out.println(cal.getTime());
}
}