One of the series of Java Pen questions (interview questions)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.