【分录题】(7-7)阅读程序 写出程序运行结果。 //写出程序运行结果 class Leg {// 腿 private int le

大学网课 已帮助 人

【分录题】(7-7)阅读程序,写出程序运行结果。 //写出程序运行结果 class Leg {// 腿 private int length; public Leg(int length) { this.length = length; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } } class Head {// 头 private String type;// 类型 public Head(String type) { this.type = type; } public String getType() { return type; } public void setType(String type) { this.type = type; } } class Person { private String name;//

【分录题】(7-7)阅读程序 写出程序运行结果。 //写出程序运行结果 class Leg {// 腿 private int le

热搜:二审程序和审判监督程序的区别

回答

共1条回复

  • B 本题考查的是Java增量运算符”十+”。x++是先使用后加l,即首先使用X的值进行表达式的计算,然后才对x的值加1。而++x是先加1后使用,即首先对x的值加1,然后使用X的值进行表达式的计算。本题首先生成一个整型变量c,其初始值为5。第-条输出语句输出c的初始值,即5。然后,第二条输出表达式c++的结果,即先输出c的值,然后才对c的值加1.所以,第二条输出语句输出的是5,输出后C的结果才为6。最后-条输出语句输出结果为6。因此,本题的正确答案为B。