java面试四 运算符测试

1 根据根除的代码,选出正确的答案

public class Test {

 
 public static void main(String[] args) {
   int i = 0 ;
   int j = 8 ;
   for(int k = 0 ; k < 10; k++){
    if(  ( ++i > 2 ) || ( --j > 2)    ){
      i++;
      //System.out.println( "i = " + i + " j = " + j  );
    }
   
   }
  System.out.println(i + "和" +j);

 }

}

 

A 19和7

B 20和-2

C 20和-1

D 20和7

E 19和-2

 

 

2 正确答案选 D

3 以下是程序运行结果

i = 2 j = 7
i = 4 j = 7
i = 6 j = 7
i = 8 j = 7
i = 10 j = 7
i = 12 j = 7
i = 14 j = 7
i = 16 j = 7
i = 18 j = 7
i = 20 j = 7
20和7


 

 

 

你可能感兴趣的:(java面试题)