java-based day2

 

02.01_Java language basis (Overview and use constants) (master)

  • A: What is constant

    • Its value can not be changed during program execution

  • B: Classification constants in Java

    • Literals

    • Custom constant (say object-oriented portion)

  • C: Classification of literals

    • String constants enclosed in double quotes contents of an integer constant all integers decimal constant all the decimal character constants in single quotes the content, which can put a single digit, single letters, or single symbols Boolean constants more specific, only the true and false air constant null (array part explain)

  • D: Case presentation

    • Constant output various output statement. null does not demonstrate

02.02_Java language basis (hex overview and two, eight, hexadecimal graphic) (understand)

  • A: What is binary

    • Hex: is the binary system, is a method for people to carry provisions. For any band --X band, it means that the number of operations is on a location every X into one. Every binary is a binary, octal is every eight into a decimal is a decimal every, every hex is a hexadecimal.

    • For example, seven days, seven decimal week twelve months a year, ten binary

  • B: Decimal origin

    • The origin of decimal is because humans have ten fingers

  • C: Binary origin

    • In fact, the binary source with China, look at historical records

    • 18th century German philosophy of mathematics master Leibniz from his missionary friend Bao Weite sent his Latin translation of "Book of Changes", read the composition of the structure of gossip, surprised to find that the basic primes (0) (1 ), or "Book of Changes" Yin Yao yao- - and __ Yang Yao, its binary system is binary, and that this is the world's most advanced binary mathematics. Invention and application of computer, one of the important symbol of the 20th century is known as the third technological revolution, which is the binary operation mode. It not only proved Leibniz's principle is correct, but also proved that the "Book of Changes" Mathematics and Physics is extraordinary.

  • D: octal origin

    • Any data present in the computer are in binary form. Binary electrical signal by the switch from the early evolution. A is an integer in memory as binary, but the use of a long list of values ​​or zeros be cumbersome to use.

    • So we wanted to shorten the long list of points, the binary representation with a three. It can take three to 7. The maximum is more than 7 to carry, and this is octal.

  • E: Hex origin

    • But for too long octal or binary becomes longer, so the situation represented by a four-bit binary appears, maximum four bits is 15, which is the hexadecimal.

  • F: Hex different manifestations of the same data characteristics

    • The larger the band, the shorter form of expression

02.03_Java language basis (different forms of binary data) (master)

  • A: binary data forms

    • Of 1s and 0s. To 0b (b can be uppercase or lowercase) at the beginning (JDK1.7 version can represent a binary)

  • B: octal data forms

    • The 0,1, ... 7 components. Beginning with 0

  • C: decimal data forms

    • The 0,1, ... 9 components. The default is a decimal integer

  • D: hexadecimal data forms

    • A 0,1, ... 9, a, b, c, d, e, f (upper or lower case). Beginning with 0x

  • E: Case presentation

    • Different binary output performance data 100.

    • 0b100

    • 0100

    • 100

    • 0x100

02.04_Java language basis (any hex to decimal conversion diagram) (understand)

  • A: arbitrary binary to decimal conversion principle

    • Factor: is the data on each bit.

    • Base: X-band, the base is X.

    • Right: the right, numbered from 0, the corresponding bit is the number on the right of this bit.

    • Results: The right power coefficient * base can be added.

  • B: Paint practice

    • Binary - Decimal

    • Octal - Decimal

    • Hex - Decimal

02.05_Java language basis (decimal to binary conversion of any diagram) (understand)

  • A: decimal to hexadecimal conversion principle any

    • In addition to the plot to take down more than

  • B: Paint practice

    • Decimal - Binary

    • Decimal - Octal

    • Decimal - hexadecimal

02.06_Java language foundation (fast binary conversion method) (understand)

  • A: 8421 code and the features

    • 8421 yards is a popular name in mainland China, the code BCD 8421 yards is the most commonly used. In this encoding each bit binary code is representative of a fixed value 1, each bit of the decimal number represented by 1 together, the result is that it represents the decimal numerals.

  • B: binary and decimal conversion performed by way of 8421 yards

  • C: Binary to octal easy way

  • D: Binary to hexadecimal easy way

02.07_Java language basis (anti-code complement the original code) (understand)

  • A: Why learn original code anti-code complement?

    • To learn later cast, if you do not know will not read the original countervailing results

  • B: There are several ways the symbol notation data

    • Original code

      • It is a binary fixed-point notation, i.e., the most significant bit is the sign bit, "0" indicates positive and "1" represents a negative value indicates the size of the remaining bits.

      • By one byte, i.e. 8 bits, and indicates +7 -70 (sign bit) 00001111 (sign bit) 0000111

    • Inverted

      • Positive anti-code the same as their original code; negative inverted by the original code is its bit inverse, except for the sign bit.

    • Complement

      • Complement positive number of the same original code thereto; negative complement is added to the last bit 1 in its inverted.

02.08_Java language foundation (formerly code practice anti-code complement) (understand)

  • A: Known original code twos complement

    • 0b10110100

  • B: Known complement seeking original code

    • 0b11101110

02.09_Java language basis (Overview and format variables) (master)

  • A: What is a variable

    • During program execution, its value may change occurs in an amount within a certain range

  • B: Definition Format variables

    • Variable name = value data type variables;

  • C: Why do you want to define variables

    • To continue to store the same type of constant, and can be reused

02.10_Java language basis (Overview of data types and classification) (master)

  • A: Why is there data types

    • Java is a strongly typed language, for each data has a clearly defined data type specific, allocated memory space of different sizes in memory

  • B: the Java data type of classification

    • Basic data types

    • Reference data types

      • Object-oriented part of the explanation

  • C: basic data type classification (eight kinds of class 4)

    • Integer

      • byte of one byte to 127 -128

      • accounting for short words -2 ^ 15 to 2 ^ 15-1

      • int total of four bytes -2 ^ 31 to 2 ^ 31-1

      • long occupies eight bytes -2 ^ 63 to 2 ^ 63-1

    • Float

      • float total of four bytes of single-precision -3.403E38 ~ 3.403E38

      • eight bytes representing double double -1.798E308 ~ 1.798E308

    • Character

      • char two bytes 0 to 65535

    • Boolean

      • boolean

        • boolean theoretically account for a byte-eighths, because a switch you can decide whether true or false, but the java boolean type is not explicitly specify his size

02.11_Java language based (define different data types of variables) (master)

  • A: Case presentation

    • Different basic types of data defined variable, and outputs

    • Assignment when the attention of float type, long type

02.12_Java language basis (Note the use of variables) (master)

  • A: Case presentation

    • a: the scope of the problem

      • The same area can not use the same variable name

    • b: initial value problem

      • Local variables must be assigned before use

    • c: a statement can define several variables

      • int a,b,c...;

02.13_Java language basis (implicit conversion converts the data type) (master)

  • A: Case presentation

    • a:int + int

    • b:byte + int

  • B: Java in the default conversion rule

    • A small range of data types and large range of operation data types, data type will first small upgrade to a large, recalculation

  • C: drawing interpretation byte + int type of problem

02.14_Java language basis (data type conversion of the cast) (master)

  • A: Forced conversion issues

    • int a = 10;

    • byte b = 20;

    • b = a + b;

  • B: the cast format

    • b = (byte)(a + b);

  • C: cast Notes

    • If the result exceeds the data type of the assigned ranges and you will get the desired results differ

02.15_Java language basis (face questions of variables and constants adding the sum of the difference) (master)

  • A: Case presentation

    • Interview questions: Look at the following program if there are problems, if there are problems, please point out and explain the reasons.

    • byte b1 = 3;

    • byte b2 = 4;

    • byte b3 = b1 + b2;

      • Two ways to answer this question

      • b1 and b2 are two variables, the values ​​of variables which are stored variable, the JVM is running in the program can not determine which specific values

      • When byte type of variables during the operation, the type is automatically promoted to an int

    • byte b4 = 3 + 4;

      • 3 and 4 are constants, java has constant optimization mechanism, is a direct result of the 3 and 4 are assigned to b4 at the time of compilation

02.16_Java language basis (ranging from long and float who is great who is small) (understand)

  • When the mixing operation, byte, short, char not interchangeable, automatically promoted to an int type, other types of small mixing operation is promoted to a large data type

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

    • long: 8 bytes

    • float: 4 bytes

    • IEEE754

    • 4 bytes are 32 bits

    • 1 is the sign bit

    • 8 is an exponent

    • 00000000 11111111

    • 0 to 255

    • 1-254

    • -126 to 127

    • 23 is a bit mantissa

    • Each index bit subtract 127

    • A: their different underlying storage structures.

    • B: Data represented float range larger than the long range

      • long:2^63-1

      • float:3.410^38 > 210^38 > 28^38 = 22^3^38 = 2*2^114 > 2^63-1

02.17_Java language basis (characters and strings involved in computing) (master)

  • A: Case presentation

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

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

    • Results know by looking at the value 'a' is the number, whereby the ASCII code table extraction

  • B: Summary table of ASCII code

    • Remember the three values:

      • '0' 48

      • 'A' 65

      • 'a' 97

  • C: Case presentation

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

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

  • D: + participation in a character string character string is referred to a connector

    • System.out.println("5+5="+5+5);

    • System.out.println(5+5+"=5+5");

02.18_Java language basis (char data type) (master)

  • A: char c = 97; 0 to 65535

  • B:? Character char Java language can be stored in a Chinese characters do and why?

    • can. Because the Java language uses Unicode encoding. Unicode encoding each character occupies two bytes. Chinese also accounted for two bytes

    • So, Java characters can be stored in a Chinese characters

02.19_Java language basis (basic use of arithmetic operators) (master)

  • A: What is the operator

    • It is the symbol of constants and variables operations.

  • B: Classification operator

    • Arithmetic operators, assignment operators, comparison (or the relationship condition) operators, logic operators, bitwise operators, tris mesh (RMB) operator

  • C: arithmetic operators which

    • +,-,*,/,%,++,--

  • D: Note:

    • a: + Number three purposes in java, represents a positive number, do adder, connected to the string,

    • b: integer division can only get integer. If you want a decimal floating point numbers must change the data type

    • c: / divide operation are commercially acquired, and the acquired% is the remainder of the division operation

    • Operators%

      • When the right side is smaller than the absolute value of the absolute value of the left, the result is left

      • When the left or right of the absolute value equal to a multiple of the right, the result is 0

      • When the absolute value of the left is greater than the absolute value of the right, the result is the remainder

      • % Symbols and operators results only left a relationship, regardless of the right

      • Any positive integer is not 0% 2 1 The results can be used as a switching condition

02.20_Java language basis (arithmetic operators ++ and - usage) (master)

  • A: ++, - operator effect

    • From plus (+) from the minus (-) operator

    • ++: from Canada. The original data +1

    • -: decrement. The original data -1

  • B: Case presentation

    • a: alone:

      • On the same front and rear operand effect. (This usage of our more common)

    • b: to participate in operations using:

      • In front of the operand, to increment or decrement, and then participate in operation.

      • Operand placed behind the first operation involved in, and then increment or decrement.

02.21_Java language basis (arithmetic operators ++ and - practice) (master)

  • A: Case presentation

    • Please calculate the value of a, b, c, respectively?

    • int a = 10; int b = 10; int c = 10;

      a = b++;
      c = --a;
      b = ++a;
      a = c--;
  • B: Case presentation

    • Please calculate the values ​​of x, y, respectively?

      you x = 4; you y = (x ++) + (++ x) + (x * 10);

  • C: interview questions

    • byte b = 10;

    • b++;

    • b = b + 1;

    • NOT true error will ask, Why

02.22_Java language basis (basic use of the assignment operator) (master)

  • A: assignment operator which

    • a: basic assignment operator: =

      • = The right side of the data assigned to the left.

    • B: Extended assignment operator: + =, - =, * =, / =,% =

      • + = The left and right to make additions, and then assigned to the left.

02.23_Java language basis (assignment operators face questions) (master)

  • A: Case presentation

    • Interview questions: Look at the following program if there are problems, if there are problems, please point out and explain the reasons.

    • short s=1;s = s+1;

    • short s=1;s+=1;

02.24_Java language basis (basic use of relational operators and Notes) (master)

  • A: What are the relational operator (comparison operators, operator condition)

    • ==,!=,>,>=,<,<=

  • Precautions:

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

    • "==" can not be written as "=."

02.25_day02 summary

  • The summary of today's knowledge points again.

Guess you like

Origin www.cnblogs.com/wudaokoubigbrother/p/11841120.html