8.有如下一段Java程序:importjava.io.*;publicclassQuiz{publicstaticvoidmain(Stringargs[]){intc;System.out.print("Go");try{System.out.print("in");c=System.in.read();if(c==...
8.有如下一段Java 程序:
import java.io.*;
public class Quiz{
public static void main(String args[]){
int c;
System.out.print("Go ");
try{
System.out.print("in ");
c=System.in.read();
if (c==´0´) {throw new MyException();}
System.out.print("this ");
} catch(IOException e){}
catch(MyException e){
System.out.print("that ");
} finally{
System.out.print("way.\n");
}
}
}
class MyException extends Exception{}
运行该程序后输入字符´0´,请问运行结果为何? __________
(A)Go in this way. (B)Go in this that way.
(C)Go in that (D)Go in that way.
9.接口中可以有的语句为________(从ABCD中多选);一个类可以继承_____ 父类, 实现______接口; 一个接口可继承______ 接口(从EF中单选)。
(A)int x;
(B)int y=0;
(C)public void aa();
(D)public void bb(){System.out.println("hello");}
(E)仅一个
(F)一个或多个
10. 以下程序测试String类的构造函数,试选出其运行结果。
class stringTest{
public static void main(String args[]) {
String s1 = new String();
String s2 = new String("String 2");
char chars[] = { 'a',' ','s','t','r','i','n','g' };
String s3 = new String(chars,2,6);
System.out.println("The String No.1 is " + s1);
System.out.println("The String No.2 is " + s2);
System.out.println("The String No.3 is " + s3);
}
}
(A)The String No.1 is
The String No.2 is String 2
The String No.3 is stri
(B)The String No.1 is
The String No.2 is String 2
The String No.3 is string
(C)The String No.1 is
The String No.2 is String 2
The String No.3 is strin
(D)以上都不对。
展开