1)
1 Public class Test01 {23 Public Static void Main (string[] args) {4 int a = 5; 5 System.out.println ("value is" + ((a<5) 10.9:9)); 6 }78 }
Output Result: 9.0
Analysis: Because there are 10.9, data type automatic conversion occurs, 9 is automatically converted to 9.0, so the output is 9.0. Detailed data type conversion, please see my blog http://www.cnblogs.com/XuGuobao/p/7229881.html
2)
1 Public classTest03 {2 3 Public Static voidMain (string[] args) {4 intm = 5,n = 5;5 if((M! = 5) && (n++ = 5)){}6System.out.println ("A." +n);7 8m = n = 5;9 if((M! = 5) & (n++ = 6)){}TenSystem.out.println ("B." +n); One Am = n =5; - if((M = = 5) | | (n++ = = 5)){} -System.out.println ("C." +n); the -m = n =5; - if((M = = 5) | (n++ = = 6)){} -System.out.println ("D." +n); + - intA = 1,b = 2; + intc = A &b; ASystem.out.println ("A% B" +c); at } - -}
The output is:
C.w
B.6
C.5
D.6
A% B0
One of the series of Java Pen questions (interview questions)