首页 > 试题广场 >

运算结果类型相同的( &nb...

[不定项选择题]
运算结果类型相同的(     )
  • 9.0/2.0  9.0/2
  • 9/2.0  9/2
  • 9.0/2  9/2*1.0
  • 9/2  9.0/2.0
A.double/double=double     double/int=double
B.int/double=double            int/int=int
C.double/int=double            int/int*double=double
D.int/int=int                         double/double=double
发表于 2020-08-01 09:59:17 回复(0)
毫无疑问这道题有点坑,注意看清题目啊,运算结果 类 型 相同😥😥

发表于 2019-09-08 15:08:19 回复(3)
    public static void main(String[] args) {
        System.out.println(getType(9.0/2.0));//Double
        System.out.println(getType(9.0/2));//Double
        System.out.println(getType(9/2.0));//Double
        System.out.println(getType(9/2));//Integer
        System.out.println(getType(9/2*1.0));//Double
    }
    public static String getType(Object o){
        return o.getClass().toString();
    }
发表于 2019-09-11 10:38:42 回复(0)
发表于 2019-08-29 10:09:54 回复(1)
double/double=double     double/int=double
int/double=double            int/int=int
double/int=double            int/int*double=double
int/int=int                         double/double=double
发表于 2021-07-21 17:01:21 回复(0)
我透,没注意审题,是结果类型相同不是结果相同。
发表于 2021-03-06 19:02:16 回复(0)
注意审题啊,问的是结果的类型,不是计算结果
发表于 2022-08-22 11:14:18 回复(0)
优先看被除数的类型
发表于 2021-12-01 14:19:13 回复(0)
类型不同,不是结果不同。我与你们出现了差距。
发表于 2021-09-22 23:26:06 回复(0)
ac
发表于 2021-06-18 13:36:18 回复(0)
在没有标注的情况下,编译器把不同类型的值运算后都是 从小到大方向移动 char -> int ->float -> double 
例如 int + char = int
        int + char +double = double
发表于 2020-11-27 12:26:27 回复(0)