次のコードを実行したときの画面出力は?
class Wallet{
  int money;
  
  void spend(int s){
    if(money >= s) money -= s;
  }
  void earn(int e){
    money += e;
  }
  int check(){
   return money;
  }
  void set(int s){
    money = s;
  }
}

class Test
{
  public static void main(String[] args){
    Wallet mine = new Wallet();
    mine.set(1000);
    mine.spend(700);
    mine.earn(150);
    mine.spend(500);
    System.out.println("所持金:"+mine.money+"円");
  }
}
□選択肢
(1) 450
(2) -50
(3) 0
答えは  (1)  です
※答えはタッチで!!

0
0