Java post-class jobs

Source: Internet
Author: User

I. Enumeration type

Program:

Operation Result:

Conclusion:

An enumeration type is a reference type, not an original type, and each of his specific values refers to a specific object. The same value refers to the same object. The values of the enumeration variables can be compared directly with "= =" and "Equals ()", and "= =" and "Equals ()" are the same for enumeration types.

Second, the Code

The original code: the highest bit is the sign bit, "0" for the positive, "1" for the negative, and the remaining bits to indicate the size of the value.

Anti-code: The inverse code of positive number is the same as its original code, and the inverse code of negative number is the inverse of its original code, except the sign bit. For example {Original code 10010 = Inverse Code 11101 (10010,1 is a character number, it is negative) (11101) binary =-20 binary}

Complement: The complement of a positive integer is the same as the original code, and the complement of the negative integer is the inverse of the code plus 1.

Java uses "complement".

Iii. Scope of variables

The masking principle of a variable of the same name: two or more variables with the same name, when different values are defined, when used, within the range used, the value of the variable is the nearest (preceding) definition from his.

The result is:

Iv. Types of data

Char 8-bit binary number range is-2 of 7 square to 2 7-square-1

BYTE 8-bit signed integer-any integer between 128 and 127

Short 16-bit unsigned integer-any integer between 32768 and 32767

int 32-bit signed integer-2 of the 31-square-to-2-31-square-by-1 arbitrary integer

Long 64-bit signed integer-2 of 63 square to 2 of any integer between 63

Float 32-bit single-precision floating-point number double 64-bit double-precision floating-point number.

Conclusion: Java converts from a low-level type to a high-level type, where a data type with a relatively small range of values is converted to a data type with a relatively large range of values.

Program:

Results:

Conclusion:

The result of a calculation using a numeric value of type Double is imprecise.

Analysis: The computer can only recognize the binary, all the data will be converted to binary at the end. For example, 2.4 in the source program is decimal, to be converted to binary, but 2.4 of the binary is not accurate 2.4, just close to 2.4, actually 2.3 999 999 999 999 999, floating-point number consists of two parts: exponent and Mantissa, and then the binary and decimal conversion of floating-point numbers, When a floating-point number participates in the calculation, the conversion process becomes unpredictable and irreversible.

What is the output of the following code?

Program:

Results:

Conclusion:

The two plus signs after the previous output statement are character connectors, the first plus sign in the next output statement is the plus of the mathematical addition, and the next plus is the character connector.

Java post-class jobs

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.