2022\03\02第三次作业

2022\03\02第三次作业

Question1:计算下列表达式的结果:
10/3=? ; 10/5 = ? ; 10 % 2 = ? ; -10.5%3 = ?;
Answer1:10/3=3 ; 10/5 = 2 ; 10 % 2 = 0 ; -10.5%3 = -1.5;
Question2:试说出下面代码的结果:

package Day03;

public class Homework02 {
    public static void main(String[] args){
        int i = 66;
        System.out.println(++i+i);
    }
}

Answer02:134;
Question03:在JAVA中,以下赋值语句中正确的是:(CD)
A)int num1 = (int)“18”;
B)int num2 = 18.0;
C)double num3 = 3d;
D)double num4 =8;
E)int i = 48;char ch = i + 1;
F)byte b = 19;short s = b + 2;
Question04:试写出将String转换成double类型的语句,以及将char类型转换成String类型的语句,举例说明即可。
Answer04:

package Day03;

public class Homework04 {
    public static void main(String[] args){
        String s = "18.8";
        double d1 = Double.parseDouble(s);
        char m = '泽';
        String d2 = m + "";
        System.out.println(d1 + d2);
    }
}
上一篇:SQL(五)


下一篇:java中判断一个String字符串或字符数组中包含某个字段