次のコードを実行したときの画面出力は?
class Wallet
{
  int total;
  void earnMoney(int m){
    total+=m;
  }
  void spendMoney(int m){
    total-=m;
  }
  int checkMoney(){
    return total;
  }
}

class Test
{
  public static void main(String[] args){
    Wallet mywallet=new Wallet();
    mywallet.total=0;
    mywallet.earnMoney(10000);
    mywallet.spendMoney(4000);
    System.out.print(mywallet.checkMoney());
  }
}
□選択肢
(1) 10000
(2) 4000
(3) 6000
答えは  (3)  です
※答えはタッチで!!

0
0