REPORT#4

Q23

public class test{
    pubic static void main(String atgs[]){
      int x,y;
      x =100;  x+=1; x--; y=200 + x;
      System.out.println(y++);
	  System.out.println(y);  //出力結果を追加
    }
  }
実行結果
300
301

考察

    System.out.plintln(y++)はインクリメント演算子が、yの後ろの方にあるので、出力結果が終わった直後に1が加算される。
    

Q24

public class test{
    pubic static void main(String atgs[]){
      int a=0, x=0;
	  a=5; a+=3; x= ++a;
      System.out.println(x);
    }
  }

実行結果

9

考察

出力する前に行っている、x=++aは、aをインクリメントした値をxに代入するのでこのような結果になる。 

Q25

public class test{
    pubic static void main(String atgs[]){
      int a=9,b=3;
      a/=b; 
      System.out.println(a%=b);
    }
  }

実行結果

0

考察