2nd, 3rd

Source: Internet
Author: User
Tags bitwise operators integer division

2nd, 3rd
02.01 _ Java language basics (overview and use of constants) (master)

  • A: What is A constant?
    • The value of the program cannot be changed during execution.
  • B: Classification of constants in Java
    • Nominal value constant
    • Custom constants (Object-Oriented)
  • C: Classification of literal Constants

    • Content of A String constant enclosed in double quotation marks
    • All integers of an integer constant
    • Decimal constant all decimal places
    • The content of a character constant enclosed in single quotes. It can only contain a single number, a single letter, or a single symbol.
    • Boolean constants are special, only true and false.
    • Null constant (array)
  • D: Case Study

    • Outputs Various constants using output statements. Null is not demonstrated
02.02 _ basics of Java language (hexadecimal overview and diagram of binary, octal, and hexadecimal) (understanding)
  • A: What is hexadecimal
    • Hexadecimal: it is the carry-in system, a carry-in method defined by people. For any kind of hexadecimal-X hexadecimal, it indicates that the number operation at a certain position is regarded as one X. Binary is the result of two-to-one Operations, octal is the result of eight-to-one Operations, decimal is the result of ten-to-one operations, and hexadecimal is the result of sixteen-to-one operations.
    • For example, there are seven days in a week, in hexadecimal format, 12 months in a year, and 12 months in a week.
  • B: The Origin of decimal
    • Decimal occurs because humans have ten fingers.
  • C: The Origins of Binary
    • In fact, the binary source and China, please refer to the historical records
    • In the 18th century, German Mathematical Philosophy master leveniz read the composition structure of gossip from his missionary friend Bao Witt to his Latin translation "Yijing" and was surprised to find its basic prime number (0) (1) Yin Yi yao--and _ Yang Yu in Yijing, whose hexadecimal system is binary, and he thinks this is the most advanced mathematical system in the world. The invention and application of computer, called one of the third important symbols of the technological revolution in the 20th century, its computing mode is binary. It not only proves that leveniz's principle is correct, but also proves that the Book of Changes is remarkable.
  • D: the origin of gossip
    • Any data exists in binary form in a computer. Early binary systems evolved from electrical switch. An integer is also binary in the memory, but it is troublesome to use a large string of 1 or 0 values.
    • Therefore, we want to shorten a large string of vertices and represent the three digits in binary with one digit. The maximum value that can be obtained from the three digits is 7. If it exceeds 7, it will be carried. This is octal.
  • E: the origin of hexadecimal
    • However, it is still relatively long for a long binary to octal, so four binary bits are used to represent one bits. the maximum value of the four binary bits is 15, which is the hexadecimal system.
  • F: different operating systems present the characteristics of the same data format
    • The larger the hexadecimal value, the shorter the representation.
02.03 _ Java language basics (representation of different hexadecimal data) (master)
  • A: binary data representation
    • Consists of 0, 1. It must start with 0 B (B can be capitalized or lowercase) (JDK1.7 can represent binary)
  • B: octal Data Representation
    • From 0, 1 ,... 7. Starting with 0
  • C: decimal data representation
    • From 0, 1 ,... 9. The integer is in decimal format by default.
  • D: hexadecimal Data Representation
    • From 0, 1 ,... 9, a, B, c, d, e, f (case sensitive ). Starting with 0x
  • E: Case Study
    • Output 100 of data in different hexadecimal formats.
    • 0b100
    • 0100
    • 100
    • Zero x 100
02.04 _ Java language basics (Conversion diagrams from any hexadecimal to decimal) (understanding)
  • A: conversion principle from any base to decimal
    • Coefficient: The data on each bit.
    • Base Number: X in hexadecimal notation. The base number is X.
    • Right: Start from 0 on the right side. The number on the corresponding bit is the right of the bit.
    • Result: The power of the coefficient * base is added.
  • B: Drawing exercise
    • Binary-decimal
    • Octal -- decimal
    • Hexadecimal -- decimal
02.05 _ basics of Java language (diagram of conversion from decimal to native) (understanding)
  • A: Principle of conversion from decimal to Italian hexadecimal
    • Except product and inverted Remainder
  • B: Drawing exercise
    • Decimal-binary
    • Decimal-octal
    • Decimal-hexadecimal
02.06 _ Java language basics (quick hexadecimal conversion method) (understanding)
  • A: 8421 yards and features
    • Code 8421 is the name of the Chinese mainland, and code 8421 is the most common type of BCD code. In this encoding method, the value 1 of every Binary Code represents a fixed value, and the number of decimal digits represented by the value 1 of each digit is added up, the result is the decimal number it represents.
  • B: mutual conversion between binary and decimal in the form of 8421 code
  • C: simple binary to octal
  • D: simple binary to hexadecimal format
02.07 _ Java language basics (original code anti-Code complement) (understanding)
  • A: Why do I need to learn the source code anti-code?
    • We will learn to force type conversion later. If you do not know the original anti-population, you will not understand the result.
  • B: several methods of Symbolic Data Representation
    • Original code
      • It is a binary fixed-point representation, that is, the highest bit is the symbol bit, "0" indicates positive, "1" indicates negative, and the remaining bit indicates the value size.
      • + 7 and-7 are represented by 8 binary digits in one byte.
      • 0 (symbol digit) 0000111
      • 1 (symbol bit) 0000111
    • Reverse code
      • A positive number is the same as its original code. A negative number is used to reverse the original code by bit, except for the symbol bit.
    • Complement
      • The positive complement is the same as the original one. The negative complement is added with 1 at the end of the reverse code.
02.08 _ Java language basics (original code verification exercises) (understanding)
  • A: Get the known source code
    • 0b10110100
  • B: Obtain the source code with known completion Codes
    • 0b11101110
02.09 _ Java language basics (overview and format of variables) (master)
  • A: What is A variable?
    • Number of changes in the value of a program in a certain range during execution
  • B: Variable Definition Format
    • Data type variable name = variable value;
  • C: Why define variables?
    • It is used to store constants of the same type and can be reused.
02.10 _ Java language basics (overview and classification of data types) (master)
  • A: Why are there data types?
    • Java is a strongly typed language. Each data type is defined with a specific data type, and memory space of different sizes is allocated in the memory.
  • B: classification of data types in Java
    • Basic Data Type
    • Reference data type
      • Object-oriented explanation
  • C: Basic Data Types (4 categories and 8 types)
    • Integer
      • Byte occupies one byte-128 to 127
      • Short occupies 2 ^ 15 ~ 2 ^ 15-1
      • Int occupies four bytes-2 ^ 31 ~ 2 ^ 31-1
      • Long occupies eight bytes-2 ^ 63 ~ 2 ^ 63-1
    • Floating Point Type
      • Float occupies four bytes-3.403E38 ~ 3.403E38 single precision
      • Double occupies eight bytes-1.798E308 ~ 1.798E308 dual-precision
    • Character Type
      • Char occupies two bytes 0 ~ 65535
    • Boolean
      • Boolean
        • Boolean theoretically occupies 1/8 bytes, because a switch can determine true and false, but the boolean Type in java does not explicitly specify its size.
02.11 _ Java language basics (defining variables of different data types) (master)
  • A: Case Study
    • Define variables of different basic data types and Output
    • Pay attention to the float type and long type when assigning values.
02.12 _ Java language basics (considerations for using variables) (master)
  • A: Case Study
    • A: Scope issues
      • The same variable name cannot be used in the same region.
    • B: initialization value
      • The local variable must be assigned a value before use.
    • C: several variables can be defined in a statement.
      • Int a, B, c ...;
02.13 _ Java language basics (implicit conversion of data type conversion) (master)
  • A: Case Study
    • A: int + int
    • B: byte + int
  • B: Default conversion rules in Java
    • Operations are performed on data types with a small value range and those with a large value range. The operation is performed on the data types with a large value first.
  • C: Draw a picture to explain the problem of byte + int type
02.14 _ Java language basics (forced conversion of data type conversion) (master)
  • A: forced conversion
    • Int a = 10;
    • Byte B = 20;
    • B = a + B;
  • B: forced conversion format
    • B = (byte) (a + B );
  • C: Considerations for forced conversion
    • If the value range of the assigned data type is exceeded, the result will be different from the expected result.
02.15 _ Java language basics (differences between variable addition and constant addition in the interview questions) (master)
  • A: Case Study
    • Interview Questions: Check whether there is a problem with the following program. If there is a problem, please point out and explain the reasons.
    • Byte b1 = 3;
    • Byte b2 = 4;
    • Byte b3 = b1 + b2;
      • Answer this question in two ways
      • B1 and b2 are two variables, and the values stored in the variables are changed. Therefore, the JVM cannot determine the specific values in the variables during the program running.
      • The byte type variable is automatically upgraded to the int Type During computation.
    • Byte b4 = 3 + 4;
      • Both 3 and 4 are constants. java has a constant optimization mechanism, which is to assign values of 3 and 4 to b4 directly during compilation.
02.16 _ Java language basics (who is the value range of long and float?) (understanding)
  • During the hybrid operation, byte, short, and char are not converted to each other, and the data types are automatically upgraded to int. For other types of hybrid operations, the small data types are upgraded to large ones.

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

    • Long: 8 bytes

    • Float: 4 bytes
    • IEEE754
    • The four bytes are 32 binary digits.
    • The first digit is the symbol bit.
    • Eight digits are exponential digits.
    • 00000000 11111111
    • 0 to 255
    • 1 to 254
    • -126 to 127
    • The 23th digit is the ending digit.
    • Each index bit minus 127

    • A: their underlying storage structures are different.

    • B: float indicates that the data range is larger than long.
      • Long: 2 ^ 63-1
      • Float: 3.410 ^ 38> 210 ^ 38> 2*8 ^ 38 = 22 ^ 3 ^ 38 = 22 ^ 114> 2 ^ 63-1
02.17 _ Java language basics (character and string involved in computation) (master)
  • A: Case Study

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

    • The result shows the value of 'A', which leads to the ASCII code table.

  • B: ASCII code Table Overview
    • Remember three values:
      • '0' 48
      • 'A' 65
      • 'A' 97
  • C: Case Study
    • System. out. println ("hello" + 'A' + 1 );
    • System. out. println ('A' + 1 + "hello ");
  • D: + is called a string connector when a string is involved.
    • System. out. println ("5 + 5 =" + 5 + 5 );
    • System. out. println (5 + 5 + "= 5 + 5 ");
02.18 _ basic Java language (char data type) (master)
  • A: char c = 97; 0 to 65535
  • B: Can char in Java store a Chinese character? Why?
    • Yes. Java uses Unicode encoding. Each character in Unicode encoding occupies two bytes. Chinese also occupies two bytes
    • Therefore, the characters in Java can store a Chinese character
02.19 _ basic Java language (basic usage of Arithmetic Operators) (master)
  • A: What is an operator?
    • It is the symbol used to operate constants and variables.
  • B: Operator Classification
    • Arithmetic Operators, value assignment operators, comparison (relational or conditional) operators, logical operators, bitwise operators, and three-object (Meta) Operators
  • C: What are arithmetic operators?
    • +,-, *,/, %, ++ ,--
  • D: Note:
    • A: the plus sign has three functions in java, representing the positive number, performing addition operations, and connecting character strings.
    • B: Only integers can be obtained for integer division. If you want to get a decimal number, you must change the data to the floating point type.
    • C: // obtains the operator of the division operation. % obtains the remainder of the division operation.
    • % Operator
      • When the absolute value on the left is smaller than the absolute value on the right, the result is left.
      • When the absolute value on the left is equal to the right or a multiple on the right, the result is 0.
      • When the absolute value on the left is greater than the absolute value on the right, the result is the remainder.
      • % The symbols of the operator result are only related to the left side and the right side.
      • Any positive integer % 2 returns either 0 or 1 as a switching condition.
02.20 _ Java language basics (Arithmetic Operators ++ and -- usage) (master)
  • A: ++, -- operator
    • Auto-increment (++) Auto-increment (--) Operation
    • ++: Auto-increment. Add 1 to the original data
    • --: Auto-subtraction. Perform-1 on the original data
  • B: Case Study
    • A: used separately:
      • Put it in front of the operand and the effect is the same. (This is a common usage)
    • B: used for calculation:
      • Put it in front of the operand, First Auto-increment or auto-increment, and then participate in the operation.
      • After the operand, perform the operation first, then auto-increment or auto-increment.
02.21 _ Java language basics (Arithmetic Operators ++ and -- exercises) (master)
  • A: Case Study

    • Calculate the values of a, B, and c respectively?
    • int a = 10;        int b = 10;        int c = 10;        a = b++;        c = --a;        b = ++a;        a = c--;        
  • B: Case Study

    • Calculate the values of x and y respectively?

      int x = 4;        int y = (x++)+(++x)+(x*10);        
  • C: Interview Questions
    • Byte B = 10;
    • B ++;
    • B = B + 1;
    • Which of the following statements will report an error? Why?
02.22 _ basic Java language (basic usage of value assignment operators) (master)
  • A: What are the assignment operators?

    • A: Basic Value assignment operator: =

      • Assign the value of = to the left.
    • B: Extended value assignment operator: + =,-=, * =,/=, % =

      • + = Add to the left and right, and assign the value to the left.
02.23 _ basics of Java language (interview questions of the value assignment operator) (master)
  • A: Case Study
    • Interview Questions: Check whether there is a problem with the following program. If there is a problem, please point out and explain the reasons.
    • Short s = 1; s = s + 1;
    • Short s = 1; s + = 1;
02.24 _ basic Java language (basic usage of Relational operators and precautions) (master)
  • A: What are Relational operators (comparison operators and conditional operators)
    • = ,! =,>, >=, <, <=
  • Note:

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

    • "=" Cannot be written as "= ".

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.