package oop4;

学习 时间:2026-04-08 23:40:13 阅读:4013
package oop4;public class as {\x05static class VolcanoRobot {\x05\x05String status;\x05\x05int speed;\x05\x05float temperature;\x05\x05void checkTemperature() {\x05\x05\x05if (temperature > 660) {\x05\x05\x05\x05status = "returning home";\x05\x05\x05\x05speed = 5;\x05\x05\x05}\x05\x05}\x05\x05void showAttributes() {\x05\x05\x05System.out.println("Status:" + status);\x05\x05\x05System.out.println("Speed:" + speed);\x05\x05\x05System.out.println("Temperature:" + temperature);\x05\x05}\x05\x05public static void main(String args[]) {\x05\x05\x05VolcanoRobot dante = new VolcanoRobot();\x05\x05\x05dante.status = "exploring";\x05\x05\x05dante.speed = 2;\x05\x05\x05dante.temperature = 510;//从这开始请问是怎么执行的?\x05\x05\x05dante.showAttributes();\x05\x05\x05System.out.println("Incresing speed to 3.");\x05\x05\x05dante.speed = 3;\x05\x05\x05dante.showAttributes();\x05\x05\x05System.out.println("Changing temperature to 670.");\x05\x05\x05dante.temperature = 670;\x05\x05\x05dante.showAttributes();\x05\x05\x05System.out.println("Checking the temperature.");\x05\x05\x05dante.checkTemperature();\x05\x05\x05dante.showAttributes();\x05\x05}\x05}}

最佳回答

温柔的洋葱

清爽的溪流

2026-04-08 23:40:13

VolcanoRobot对象有三个全局变量status、speed、temperature。执行主函数时先实例化VolcanoRobot对象,然后给三个变量赋值。再后来调用showAttributes()方法输出变量的值。输出结果:Status:exploringSpeed:2Temperature:510。0Incresing speed to 3。Status:exploringSpeed:3Temperature:510。0Changing temperature to 670。Status:exploringSpeed:3Temperature:670。0Checking the temperature。Status:returning homeSpeed:5Temperature:670。0 再问: 是不是 每次都执行 System。out。println("Status: " + status); System。out。println("Speed: " + speed); System。out。println("Temperature: " + temperature);

最新回答共有2条回答

  • 冷静的白昼
    回复
    2026-04-08 23:40:13

    VolcanoRobot对象有三个全局变量status、speed、temperature。执行主函数时先实例化VolcanoRobot对象,然后给三个变量赋值。再后来调用showAttributes()方法输出变量的值。输出结果:Status:exploringSpeed:2Temperature:510。0Incresing speed to 3。Status:exploringSpeed:3Temperature:510。0Changing temperature to 670。Status:exploringSpeed:3Temperature:670。0Checking the temperature。Status:returning homeSpeed:5Temperature:670。0 再问: 是不是 每次都执行 System。out。println("Status: " + status); System。out。println("Speed: " + speed); System。out。println("Temperature: " + temperature);

上一篇 smooth(写反义词) touch (写近义词)

下一篇 在草—蝗虫—青蛙组成的生物链中,青蛙的体重增加10g,则需要消耗蝗虫