The school was moved out of downtown as the number of students had grown too_______.
A.small
B.few
C.1arge
D.many
第1题:
classNumber{publicstaticvoidmain(String[]args){try{System.out.print(Integer.parseInt("forty"));}catch(RuntimeExceptionr){System.out.print("runtime");}catch(NumberFormatExceptione){System.out.print("number");}}}结果是什么?()
A.forty
B.number
C.runtime
D.编译失败
第2题:
下列程序的运行结果是( )。 public class Sun { public static void main(String args[ ]) { int number,digits; number=53; if(number<10) digits=1; else if(number<100) digits=2; else digits=3; System.out.println(digits); } }
A.1
B.2
C.3
D.0
第3题:
下列程序的运行结果是( )。 public class Sun { public static void main(String args[ ]) { int number,digits; number=53; if(number<10) digits=1; else if(number<100) digits=2; else diglts=3; System.out.println(digits); } }
A.1
B.2
C.3
D.0
第4题:
现有:classNumber{publicstaticvoidmain(String[]aras){try{System.out.print(Integer.parselnt("forty"));}catch(RuntimeExceptionr){System.out.print("runtime");}catch(NumberFormatExceptione){system..ut.print("number");}}}结果是什么?()
A.number
B.runtime
C.fortynumber
D.编译失败
第5题:
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。
【说明】本程序实现功能:读入两个整数,第1个数除以第2个数,声明当除数为零时抛出异常类DivideByZeroException。
public class DivideByZeroException (1) {
public DivideByZeroException ( ) {
super("Attcmpted to divide by zero");
}
}
import java.io. *;
public class Example {
private static int quotient(int numerator, in)\”}t denominator) throws
DivideByZeroException {
if (denominator==0)
throw (2);
return(numerator / denominator);
}
public static void main(String args[]) {
int number1=0, number2=0, result0;
try{
System.out.print1n("Enter the first number:");
number1 = Integer. valueOf(Keyboard.getString()).intValue();
System.out.print1n("Enter the second number:");
number2 = Integer. Va1ueOf(Keyboard.getString()).intValue();
result = quotient(number1,number2);
}
catch (NumberFormatException e) {
System.out.print1n("Invalid integer entered!");
System. exit(-1);
}
catch ((3)) {
System.out.print1n(e.to String());
System.exit(-1);
}
Systcm.out.pfint1n(number1 + "/" + number2 + "=" + result);
}
}
其中, Keyboard类的声明为:
import java.io.*;
public class Keyboard{
static BufferedReader inputStream =(4)
(new InputStreamReader(System.in));
public static int getInteger() {
try(
return (Intoger.valueOf(inputStream.readLine().trim()).intValue());
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public static String getString() {
try{
return (inputStream.readLine());
} catch ((5))
{ return "0";}
}
}
第6题:
对于如下关于随机数的代码 for(int number = 0; number != 5; number = (int)(Math.random() * 10)) { System.out.println(number); } 以下描述正确的是()(2分)
A.执行时显示数字永不停止
B.执行时显示数字0后停止
C.执行时显示数字5后停止
D.执行时显示数字直到number为5后停止