Very classic Java minor issues

Source: Internet
Author: User

1. Values A and B (logical thinking questions) cannot use other intermediate variables;

2. x = x + 1, and x + = 1; under what circumstances is not true and x = x + 1 is incorrect;

3. What is the final value of J?
Int J = 0;
For (INT I = 0; I <100; I ++)
{
J = J ++;
}
System. Out. println (j );

4. What are I and j to meet the conditions?
While (I <= J & I> = J & I! = J)
{
System. Out. println ("0000 ");
}

5. What is I to meet the conditions?
If (I! = 0 & I =-I)
{
System. Out. println (I );
}

6. For (INT I = 0; I <10; I ++)
{
User user = new user ();
}
How many user objects are generated in the memory?
---------------------------- Open the coating to see the answer ----------------------------

1.
Int A = 10, B = 20;
A = A + B;
B = A-B;
A = A-B;
System. Out. println ("A =" + A + "B =" + B );

 

2.
Short x = 1;
X + = 1;
X = x + 1;
The following prompt is displayed during compilation:
Test. Java: 5: possible loss of Precision
Locate: int
Required: short
X = x + 1;
^
1 error

3. j = 0

4.
Integer I = new INTEGER (0 );
Integer J = new INTEGER (0 );
While (I <= J & I> = J & I! = J)
{
System. Out. println ("OK ");
}

5.
Int I = integer. min_value;
If (I! = 0 & I =-I)
{
System. Out. println (I );
}

6. If JVM garbage collection is not considered, 10 user objects are generated.

 

 

 

Reprint from http://www.java3z.com/cwbwebhome/article/article8/81345.html? Id = 3464

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.