java 开发培训 基础练习题 带答案
答案:
一、选择题:
1~5 :DBCBD 6~10:BACDB
二、填空题:
1.字符型、数值型 2.int、short 3.boolean 4.关键字
6.-2 7.7 8.82 9.false 10.8
三、简答题:
1. 答:byte、short、int、long、double、float、boolean、char。
2. 答:20 31 71 31 0 1 7 0 -3 -3 47
5.单精度 双精度
四、编程题:
1. 答:
public static void main(String[] args) {
int temperatureHua = 80;
double temperatureShe = 5 / 9.0 * (temperatureHua - 32); System.out.println("摄氏温度是:" + temperatureShe); }
2. 答:
public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr);
int radius;
double volume;
String str;
System.out.print("输入圆球半径: "); str = br.readLine(); radius = Integer.parseInt(str); volume = 4 * Math.PI * Math.pow(radius, 3) / 3; System.out.println("球的体积 = " + volume);
}