下列程序的执行结果是( )。 public class Test { public static void main(String args[]) { byte y=4; lon

admin2010-07-28  22

问题 下列程序的执行结果是(    )。    public class Test    {       public static void main(String args[])       {          byte y=4;          long r=80L;          System.out.println(r/y);       }    }

选项 A、20B
B、20
C、20
D、编译错误

答案2

解析 在定义long型数的时候,类似long r=80L,在数字后面加上L,当然大小写都可以,在计算机要求显示或输出时,是看不到L的;还需注意,long型占64bit,远比byte的优先级高,所以r/y的结果是long型的。
转载请注明原文地址:https://kaotiyun.com/show/Jh9p777K
0

最新回复(0)