1. Java Language Foundation (basic usage of logical operators)
2, the Java Language Foundation (logical operators && and & differences)
- A: Case Demo
- What is the difference between && and &?
- A: The end result is the same.
- The b:&& has a short circuit effect. The left side is false and the right side is not executed.
- & whether the left is false or true, the right side will execute
- B: similarly | | and | The difference? (Student self-study)
- C: Who is used in development?
3. Java Language Basics (basic usage of bitwise operators 1)
- A: What are bitwise operators
B: Case Demo
4. Java Language Basics (features of bitwise XOR or operators and interview questions)
A: Case Demo
Characteristics of bitwise XOR OR operator
^ Features: one data to another data bit XOR or two times, the number itself is unchanged.
B: Interview questions:
- Please implement the exchange of two integer variables yourself
- Note: In the course of lectures later, I did not explicitly specify the type of data, the default int type.
5. Java Language Basics (basic usage of bitwise operators 2 and interview questions)
- A: Use of case presentation >>,>>>,<<:
- <<: Left highest bit discarded, right 0
- >>: The right shift is 0, the left side is 0, the maximum is 1, the left side is 1
- >>>: Unsigned right shift whether the highest bit is 0 or 1, the left side is 0
- The results of 2 * 8 are calculated most efficiently
6. Java Language Basics (basic usage of ternary operators)
- A: The format of the ternary operator
- (Relational expressions)? Expression 1: Expression 2;
- B: Execution flow of ternary operators
- C: Case Demo
- Get the maximum value in two numbers
7. Java Language Foundation (ternary operator)
- A: Case Demo
- Compare whether two integers are the same
- B: Case Demo
- Gets the maximum value in three integers
8, the Java Language Foundation (keyboard input basic format explanation)
- A: Why use the keyboard to enter data
- A: In order to make the program data more consistent with the developed data
- B: Make the program more flexible
- B: How to implement keyboard input?
- Take the format first.
- A: Guide Package
- Format:
- Import Java.util.Scanner;
- Position:
- B: Create a keyboard entry object
- Format:
- Scanner sc = new Scanner (system.in);
- C: Getting data from an object
- C: Case Demo
- Keyboard input 1 integers, and output to the console.
- Keyboard input 2 integers, and output to the console.
9. Java Language Foundation (keyboard entry 1)
- A: Case Demo
- Keyboard input Exercise: Keyboard input two data, and the two data summed, output its results
- B: Case Demo
- Keyboard input Exercise: Keyboard input two data, get the maximum value in both data
10. Java Language Foundation (keyboard entry 2)
- A: Case Demo
- Keyboard input Exercise: Keyboard input two data, compare whether the two data is equal
- B: Case Demo
- Keyboard input Exercise: Keyboard input three data, get the maximum value of these three data
11. Java Language Foundation (sequential structure statement)
- A: What is a Process Control statement
- Process Control statement: The execution flow of the program can be controlled.
- B: Classification of flow control statements
- Sequential structure
- Select structure
- Loop structure
- C: Execution Process:
- From the top down, execute in turn.
- D: Case Demo
- Output a few words to see the effect can be
12, Java Language Foundation (select Structure if statement format 1 and its use)
- A: Select the classification of the structure
- If statement
- Switch statement
- B:IF statements have several formats
- Format 1
- Format 2
- Format 3
- Format of the C:IF statement 1
if(比较表达式) { 语句体;}
- D: Execution Process:
- The value of the comparison expression is evaluated first to see if its return value is true or false.
- If true, the statement body is executed;
- If False, the statement body is not executed;
13. Java Language Foundation (select Structure if statement considerations)
- A: Case Demo
- A: Comparing expressions whether simple or complex, the result must be a Boolean type
- B:IF Statement Control Statement Body if it is a statement, curly braces can be omitted;
- If it is more than one statement, you cannot omit it. Never omit the suggestion.
- C: Generally speaking: there is no semicolon on the left curly brace, there is no left brace for the semicolon
14, Java Language Foundation (select Structure if statement format 2 and its use)
15, the Java Language Foundation (if statement of the format 2 and ternary of the mutual conversion problem)
- A: Case Demo
- If statement and ternary operator complete the same effect
B: Case Demo
The difference between an if statement and a ternary operator
Ternary operators can be implemented using the IF statement. Conversely, it is not established.
When does the IF statement implementation not use ternary improvement?
- When the If statement controls an operation that is an output statement, it cannot.
- Why? Because the ternary operator is an operator, the operator should have a result, not an output, after the operation.
16, Java Language Foundation (select Structure if statement format 3 and its use)
17. Java Language Foundation (choose Structure if statement Format 3 exercises)
18. Java Language Foundation (select nested use of structure if statement)
- A: Case Demo
- Requirements: Get the maximum value from three data
- Nested use of the IF statement.
19, the Java Language Foundation (select structure switch statement format and its interpretation)
20, Java Language Foundation (choose the structure switch statement practice)
- A: Integer (given a value, the output corresponds to the day of the week)
21. Java Language Basics (considerations for choosing a structure switch statement)
- A: Case Demo
- A:case can only be constants, cannot be variables, and values after multiple case cannot appear the same
- Can B:default be omitted?
- It can be omitted, but it is not recommended, because it is used to prompt for incorrect conditions.
- Special cases:
- case, you can fix the value.
- A,b,c,d
- Can c:break be omitted?
- The last one can be omitted, the other best not to omit
- There is a phenomenon: case penetrating.
- In the end, we recommend not omitting
- D:default must be at the end?
- No, it can be anywhere. But the suggestion at the end.
- The end condition of the E:switch statement
- A: It's over when you hit the break.
- B: The closing curly brace to switch is over.
22. Java Language Foundation (choose Structure Switch statement practice)
- A: See Program Write results:
int x = 2;int y = 3;switch(x){ default: y++; break; case 3: y++; case 4: y++;}System.out.println("y="+y);
B: Look at the program to write the results:
int x = 2;int y = 3;switch(x){ default: y++; case 3: y++; case 4: y++;}System.out.println("y="+y);
23. Java Language Foundation (choose the difference between a struct if statement and a switch statement)
- A: Summarize the respective usage scenarios for the switch statement and the IF statement
- Switch recommends determining the fixed value when
- If it is recommended to determine the interval or range
- B: Case Demo
- Use switch statements and if statements, respectively, to achieve the following requirements:
- Keyboard entry month, output corresponding to the season
Java EE Fundamentals (iii)