Java EE Basics (ii)

Source: Internet
Author: User
Tags arithmetic operators binary to decimal bitwise bitwise operators

1. Java language Foundation (overview and use of Constants)
    • A: What is a constant
      • Its value cannot be changed during program execution
    • The classification of constants in B:java
      • Literal constants
      • Custom Constants (object-oriented Section)
    • C: Classification of literal constants

      • The contents of a string constant enclosed in double quotation marks
      • integer constant all integers
      • Decimal constant All Decimals
      • Character constants are enclosed in single quotes, with only a single number, a single letter, or a single symbol
      • Boolean constants are special, only true and False
      • Empty constant null (array part)
    • D: Case Demo

      • Output the various constants with the output Statement. NULL does not show
2. Java language Basics (overview of the system and two, eight, hex plots)
    • A: What is a binary
      • In the system: is the carry system, is a kind of carry-out method stipulated by People. For any kind of binary--x, it means that the number operation at a certain position is every x in a bit. Binary is every two in one, eight into the system is every eight into a, decimal is every ten into one, hex is 16 into ONE.
      • For example, there are seven days in a week, seven, 12 months a year, 12 binary
    • B: The origin of the decimal
      • The origin of the decimal is because humans have 10 fingers
    • C: The origin of the binary
      • In fact, the binary source and china, please read the historical records
      • 18th century German mathematical philosophy master Leibniz from his missionary friend Bowett sent his Latin translation "i ching", Read the composition of the gossip, surprised to find its basic prime number (0) (1), that is, the "i ching" of the Yin Yao Yao--and __ Yang yao, The binary system is binary, And think this is the most advanced mathematics in the WORLD. The invention and application of the computer, which was known as one of the important symbols of the third scientific revolution in the 20th century, is binary in its operation Mode. It not only proves that the principle of Leibniz is correct, but also proves that the "i ching" mathematical science is very remarkable.
    • D: The origin of the Eight-step system
      • Any data exists in the computer as a binary form. The early binary evolution of the electrical signal Switch. An integer is also binary in memory, but using a large number of 1 or 0 values is Cumbersome.
      • So I want to shorten a lot of points, the three bits in the binary are represented by ONE. The maximum value that these three bits can fetch is 7. More than 7 are rounded up, which is the Octal.
    • E: The origin of hexadecimal
      • But for the long binary into octal or longer, so the appearance of 4 bits to represent a situation, four bits maximum is 15, this is Hexadecimal.
    • F: form characteristics of the same data in different binary representations
      • The larger the system, the shorter the representation
3. Java language Foundation (presentation of different binary data)
    • A: Binary Data representation
      • Made up of 0, 1. Start with 0b (b can be uppercase or Lowercase) (JDK1.7 version can indicate Binary)
    • B: the data representation of the octal system
      • by 0,1,... 7 Composition. Start with 0
    • C: Data representation in decimal
      • by 0,1,... 9 Composition. Integers are decimal by default
    • D: data representation in hexadecimal
      • by 0,1,... 9,a,b,c,d,e,f (both Uppercase and lowercase). Start with 0x
    • E: Case Demo
      • Outputs 100 of the data in different binary performance.
      • 0b100
      • 0100
      • 100
      • 0x100
4. Java Language Foundation (any conversion plot to Decimal)
    • A: The conversion principle of any binary to decimal
      • Coefficient: is the data on each ONE.
      • Cardinality: x-binary, Cardinality is x.
      • Right: on the right, numbering starts at 0, and the number on the corresponding bit is the right of that bit.
      • Result: the power of the coefficient * radix is Added.
    • B: Drawing Exercises
      • Binary--decimal
      • Octal--decimal
      • Hexadecimal--decimal
5, the Java Language Foundation (decimal to any binary conversion plot)
    • A: the conversion principle of decimal to arbitrary binary
      • In addition to the accumulated residual
    • B: Drawing Exercises
      • Decimal--binary
      • Decimal--eight binary
      • Decimal--16 binary
6. Java Language Foundation (fast conversion METHOD)
    • a:8421 Code and features
      • 8421 yards is the Chinese mainland, 8421 yards is the most commonly used in BCD Code. In this encoding method each digit two value code 1 is represents a fixed value, each bit of 1 represents the decimal number to add up, obtains the result is it represents the decimal digit.
    • B: binary and decimal conversions by 8421 yards
    • C: a simple way to binary to octal
    • D: a simple way to binary to 16
7, Java Language Foundation (original code Anti-code Complement)
    • A: Why learn the original code Anti-code complement?
      • Later to learn to force type conversion, if you do not know the original counter-complement will not understand the results
    • B: several ways of symbolic data representation
      • Original code
        • is the binary fixed-point notation, that is, the highest bit is the sign bit, "0" means positive, "1" is negative, and the remaining bits represent the size of the Value.
        • By a byte, that is, 8 bits represents +7 and-7
        • 0 (sign Bit) 0000111
        • 1 (sign bit) 0000111
      • Anti-code
        • The inverse code of a positive number is the same as its original code, and the inverse of a negative number is a bitwise negation of its original code, except for the sign Bit.
      • Complement
        • The complement of a positive number is the same as its original code, and the complement of a negative number is the minus 1 of its inverse code.
8, the Java Language Foundation (original code Anti-code complement Practice)
    • A: known source code for complement
      • 0b10110100
    • B: known complement to seek the original code
      • 0b11101110
9. Java language Basics (overview and format of Variables)
    • A: What is a variable
      • The amount of the value that can change within a range during the execution of a program
    • B: the definition format of the variable
      • Data type variable name = Variable value;
    • C: Why to define a variable
      • Used to keep constant of the same type, and can be reused
10. Java Language Foundation (overview and classification of data types)
    • A: Why is there a data type
      • The Java language is a strongly typed language that defines specific data types for each data and allocates different sizes of memory space in memory
    • Classification of data types in B:java
      • Basic data types
      • Reference data type
        • object-oriented section Explanation
    • C: basic Data type classification (4 classes 8 Kinds)
      • Integer type
        • Byte takes one byte-128 to 127
        • Short occupies two characters -2^15~2^15-1
        • int accounted for four bytes -2^31~2^31-1
        • Long is eight bytes -2^63~2^63-1
      • Floating point Type
        • Float accounts for four bytes -3.403e38~3.403e38 single precision
        • Double is eight bytes -1.798e308~1.798e308 double precision
      • Character type
        • Char occupies two bytes 0~65535
      • Boolean type
        • Boolean
          • The Boolean theoretically accounts for one-eighth bytes, because a switch can be determined to be true and false, but the Boolean type in Java does not explicitly specify his size
11. Java Language Foundation (define variables for different data types)
    • A: Case Demo
      • Define variables of different base data types and output
      • Note the float type when assigning values, long type
12. Java language Basics (considerations for using variables)
    • A: Case Demo
      • A: Scope issues
        • The same zone cannot use the same variable name
      • B: Initialization value Issue
        • Local variables must be assigned before they are used
      • C: A statement can define several variables
        • int A,b,c ...;
13. Java Language Foundation (implicit conversion of data type Conversions)
    • A: Case Demo
      • A:int + int
      • B:byte + int
    • Default translation rules in B:java
      • A data type with a small range of values and a data type with a large range of values will first be promoted to a large, and then a small data type
    • C: drawing explains Byte+int types of problems
14. Java Language Foundation (conversion of data type Conversions)
    • A: cast Issue
      • int a = 10;
      • byte B = 20;
      • b = A + b;
    • B: The format of the cast
      • b = (byte) (a + b);
    • C: Considerations for Casting
      • If you exceed the value range of the assigned data type, The result will be different from the result you expect.
15, the Java Language Foundation (the difference between the variable addition and the constant addition of the Question)
    • A: Case Demo
      • Interview Question: See if there is a problem with the procedure below, if there is a problem, please indicate and explain the Reason.
      • BYTE B1 = 3;
      • byte B2 = 4;
      • BYTE B3 = B1 + b2;
        • Answer the question in two ways.
        • B1 and B2 are two variables, and the values stored in the variables are variable, so the JVM is unable to determine the specific values in the program Run.
        • A variable of type byte is automatically promoted to int type when the operation is performed
      • byte B4 = 3 + 4;
        • Both 3 and 4 are constants, and Java has a constant optimization mechanism, which is to assign the results of 3 and 4 to B4 directly at compile Time.
16, the Java Language Foundation (long and float value range who big who Small)
    • When mixed operations are performed, the Byte,short,char does not convert to each other, the automatic type is promoted to the int type, and the other types are mixed and the small data types are promoted to large

      • Byte,short,char--int--long--float--double

      • Long:8 bytes

      • Float:4 bytes
      • IEEE754
      • 4 bytes is 32 bits
      • 1 bits is the sign bit
      • 8-bit refers to the number of digits
      • 00000000 11111111
      • 0 to 255
      • 1 to 254
      • 126 to 127
      • 23 bits is the trailing digit
      • Minus 127 per digit

      • A: their underlying storage structure is Different.

      • The range of data represented by B:float is larger than the range of long
        • Long:2^63-1
        • float:3.410^38 > 210^38 > 2*8^38 = 22^3^38 = 22^114 > 2^63-1
17. The Java Language Foundation (character and string participation Operations)
    • A: Case Demo

      • System.out.println (' a ');
      • System.out.println (' a ' + 1);

      • By looking at the result and knowing what the value of ' a ' is, this leads to the ASCII code table

    • An overview of the B:ASCII code table
      • Remember three values:
        • ' 0 ' 48
        • ' A ' 65
        • ' A ' 97
    • C: Case Demo
      • System.out.println ("hello" + ' a ' + 1);
      • System.out.println (' a ' +1+ "hello");
    • D:+ is called a string connector in the presence of a string
      • System.out.println ("5+5=" +5+5);
      • System.out.println (5+5+ "=5+5");
18. Java Language Foundation (char data Type)
    • A:char C = 97; 0 to 65535
    • B:java character Char in a language can store a Chinese character? why?
      • OK. Because the Java language uses Unicode Encoding. Each character in the Unicode encoding occupies two bytes. Chinese is also accounted for two bytes
      • therefore, characters in Java can store a Chinese character
19. Java Language Foundation (basic usage of arithmetic operators)
    • A: What is an operator
      • is the symbol that operates on constants and Variables.
    • B: Classification of operators
      • Arithmetic operators, assignment operators, comparison (relationship or Condition) operators, logical operators, bitwise operators, Trinocular (unary) operators
    • C: What are the arithmetic operators
      • +,-,*,/,%,++,--
    • D: precautions:
      • The a:+ number has three functions in java, representing the plus sign, the addition operation, the string connector
      • B: Dividing integers can only get integers. If you want a decimal, you must change the data to a floating-point number type
      • C:/gets the quotient of the division operation,% gets the remainder of the division operation
      • % operator
        • When the left absolute is less than the right absolute value, the result is left
        • When the absolute value on the left is equal to the right or multiple of the right, the result is 0
        • When the absolute value on the left is greater than the absolute right, the result is the remainder
        • The symbol for the result of the% operator is only related to the left, not to the right
        • Any positive integer%2 result either 0 or 1 can be used as a toggle condition
20, Java Language Foundation (arithmetic operator + + And--usage)
    • The role of the A:++,--operator
      • Self-plus (+ +) self-decrement (-) operation
      • + +: Self-added. +1 of the original data
      • --: Self-reduction. 1 of the original data
    • B: Case Demo
      • A: Use alone:
        • Put in front of the operand and follow the same effect. (this usage is more common to Us)
      • B: Participate in the Operation Using:
        • Put in front of the operand, increment or decrement first, and then participate in the Operation.
        • After the operand, it participates in the operation, then increases or is Self-reduced.
21. Java language Basics (arithmetic operator + + and---exercises)
    • A: Case Demo

      • Please calculate the value of A,b,c separately?
      • int a = 10;int b = 10;int c = 10;a = b++;        c = --a;            b = ++a;        a = c--;            
    • B: Case Demo

      • Calculate the value of x, y, respectively?

        int x = 4;int y = (x++)+(++x)+(x*10);
    • C: face question
      • byte B = 10;
      • b++;
      • B = B + 1;
      • Ask which sentence will be an error, why
02.22_java Language Basics (basic Usage of assignment Operators) (master)
    • A: What are the assignment operators

      • A: Basic Assignment operator: =

        • The data on the right is assigned to the LEFT.
      • B: Extended Assignment Operator: +=,-=,*=,/=,%=

        • + = Add to the left and right, then assign to the Left.
23. Java language Basics (interview questions for assignment Operators)
    • A: Case Demo
      • Interview Question: See if there is a problem with the procedure below, if there is a problem, please indicate and explain the Reason.
      • Short S=1;s = s+1;
      • Short s=1;s+=1;
24. Java Language Foundation (basic usage of relational operators and Considerations)
    • A: What are the relational operators (comparison operators, conditional operators)
      • ==,!=,>,>=,<,<=
    • Precautions:

      • Whether your operation is simple or complex, the result is a Boolean type.

      • "=" cannot be written as "=".

Java EE Basics (ii)

Related Article

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.