下列程序的执行结果是   public class Testgg {    public static void main(String args[]) {      float t=9.0f;      int q=5;      System.out.

admin2009-01-15  0

问题 下列程序的执行结果是   public class Testgg {    public static void main(String args[]) {      float t=9.0f;      int q=5;      System.out.println((t++)*(- -q));    }   }

选项 A、40
B、36
C、36
D、40

答案4

解析 定义float t=9.0f和int q=5;而程序要求输出(1++)*(- -q)的值,这样结果一定是一个浮点型的数。
选项A)40,选项B)36都错误的认为结果应是int型的,而选项D)40.0对1++和- -q的计算过程理解错了,(t+ +)*(- -q)=9.0*4=30,这样我们便可以选出正确答案了。
转载请注明原文地址:https://www.kaotiyun.com/show/wGnp777K
0

随机试题
最新回复(0)