1. Object-oriented (overview and classification of code blocks) (Learn) (interview will ask, development is not used or very rarely)
- A: code block overview
- In Java, code enclosed in {} is called a code block.
- B: code block classification
- Depending on its location and declaration, it can be divided into local code blocks, building blocks of code, static blocks of code, and synchronizing code blocks (multithreading).
- C: Application of common code blocks
- A: Local code block
- To appear in a method; limit a variable's life cycle, release early, and improve memory utilization
- B: Building blocks of code (initialization blocks)
- Occurs outside of a method in a class, the same code is stored together in multiple constructor methods, each call construct executes, and is executed before the method is constructed
- C: Static code block
- Occurs outside of a method in a class, with a static modifier, to initialize the class, execute at load time, and execute only once.
- Typically used to load the drive
2, Object-oriented (code block interview questions)
3. Object-oriented (demonstration of succession case)
- A: Inheritance (extends)
- To have a relationship between a class and a class, the child parent class relationship
- B: Inheritance Case Demo:
- Animal, Cat, dog
- Define two properties (color, number of legs) two functions (Eat, sleep)
- C: Case Demo
- D: Case Demo
4. Object-oriented (benefits and drawbacks of inheritance)
5. Object-oriented (inheritance characteristics of classes in Java)
- Inheritance characteristics of classes in A:java
- A:java only supports single inheritance and does not support multiple inheritance. (a son can only have one father)
- Some languages are supported for multiple inheritance, format: Extends Class 1, Class 2,...
- B:java supports multilayer inheritance (inheritance system)
- B: Case Demo
- Inheritance characteristics of classes in Java
- If you want to use all the functions of this system to create objects with the lowest class
- If you want to see the common features of this system, look at the top class
6. Object-oriented (considerations of inheritance and when to use inheritance)
- A: Considerations for inheritance
- A: Subclasses can only inherit all non-private members of the parent class (member methods and member variables)
- B: Subclasses cannot inherit the constructor of the parent class, but can access the parent class construction method through the super (immediately speaking) keyword.
- C: Do not inherit for part of the function
- Project Manager name work number salary bonus
- Programmer's name work number salary
B: When to use inheritance
- Inheritance actually embodies a relationship: "is a". Person Student Teacher Fruit Apple Banana Orange
Adopt the Hypothesis method. If there are two classes, a, B. Only if they meet the one of A is B, or B is a, you can consider using inheritance.
7. Object-oriented (relationship of member variables in inheritance)
- A: Case Demo
- A: variable with no Name
- B: Variable with the same name
8. Object-oriented (the difference and application of this and super)
- What do a:this and super mean?
- This: Represents a reference to the current object, who calls me, I represent who
- Super: A reference to the parent class of the current object
- The difference between the use of B:this and super
- A: Calling member variables
- This member variable calls the member variable of this class, or it can call the member variable of the parent class
- Super. member variables call member variables of the parent class
- B: Call construction method
- This (...) calls the construction method of this class
- Super (...) constructor method for calling parent class
- C: Call member method
- This member method calls the member method of this class, or it can call the method of the parent class
- Super. Member methods call the parent class's Members method
9. Object-oriented (relationship of construction method in inheritance)
- A: Case Demo
- All constructor methods in a subclass access the constructor of the parent's hollow parameter by default
B: Why?
10. Object-oriented (considerations for constructing methods in inheritance)
- A: Case Demo
- The parent class does not have a parameterless constructor method, what about subclasses?
- Super Solution
- This resolves
- B: Precautions
- Super (...) Or this (...) must appear on the first statement of the constructor method
11. Object-Oriented (interview questions in succession)
12. Object-Oriented (member method relationship in succession)
- A: Case Demo
- A: Methods that do not have the same name
- B: Method with the same name
13. Object-oriented (overview of method overrides and their applications)
- A: What is method rewriting
- Rewrite: The child parent class appears exactly the same way (note: The return value type can be a child parent class, this we learned the object-oriented talk)
- B: Application of Method rewriting:
- You can override a method in a parent class when the subclass needs the functionality of the parent class, and the feature body subclass has its own unique content. In this way, the function of the parent class is inherited, and the content specific to the subclass is defined.
- C: Case Demo
- A: Define a mobile phone class.
14. Object-oriented (considerations for method rewriting)
15, Object-oriented (method rewrite interview questions)
16. Object-oriented (using student and teacher cases before inheritance)
- A: Case Demo
- Use pre-inheritance student and teacher cases
- Properties: Name, age
- Behavior: Eating
- Teachers have a unique approach: lectures
- Students have a unique approach: learning
17. Object-oriented (use of inherited student and teacher case)
- A: Case Demo
- Use of inherited student and teacher cases
18_ Object-oriented (CAT and dog case analysis, implementation and testing)
- A: Cat and dog Case study
- B: Case Demo
- Cat and dog Case inheritance version
- Properties: Color of hairs, number of legs
- Behavior: Eating
- Cat-specific behavior: Catching mouse Catchmouse
- Dog-specific behavior: housekeeping lookhome
19, Object-oriented (final keyword decoration class, methods and variables of the characteristics)
- A:final Overview
- B:final Modification Features
- Modifier class, class cannot be inherited
- Modifier variable, the variable becomes a constant and can only be assigned once
- Modification method, method cannot be overridden
- C: Case Demo
- Final retouching features
20. Object-oriented (final keyword decorated local variable)
21. Object-Oriented (the time of initialization of the final modified variable)
- A:final the initialization time of a modified variable
- Display initialization
- Before object construction is complete
Java EE Basics (eight)