Object Oriented (Part 1)

Object-oriented (on):
1, what is object-oriented, what is process-oriented?
2, class, object, member variables (attributes, static attributes), member methods (methods, dynamic attributes), the meaning of local variables?
3, What are the characteristics of object-oriented?
Encapsulation
private (public)
inheritance

Polymorphism
Cut
Cut
4, how to create an object in the program? (First define a class)
class name variable name = new class name ();


The scope of the class body member variables (the entire class)

The relationship between classes and classes
Association relationship (not good, the next definition describes the association relationship, relatively weak relationship)
The parameter of a method in a class is an object of another class
A member variable in a class is another class Object
* Inheritance relationship (extends keyword)
what is a kind of what
athlete
basketball player
football player
aggregation relationship
aggregation
team -> captain
combination
A component of a class is essential
* implementation relationship (interface) (implementation relationship is a kind of special inheritance relationship)
robot:
walk,
run,
jump

5, How are member variables initialized in the class?
  byte 0
  short 0
  int 0
  long 0L
  float 0.0F
  double 0.0D
  boolean false
  char '/u0000'
reference type null
(all classes, all interfaces, all arrays)
6 , How to better design a class?
Appropriate methods appear in appropriate classes
7, what is the encapsulation of a class?
Member variables modified by the private keyword can only be used in the current class
8, what is a constructor? Constructor Overloading? // The method name is the same, but the parameter list is different
Constructor: It
is the method used to construct an object
1, the constructor has no return value, and void can not be written without a return value
2, the constructor name is exactly the same as the class name
3, When defining a class, if no constructor is written, a constructor with empty parameters will be generated by default
. When there is a constructor with parameters defined in a class, the constructor with empty parameters will disappear ( If you want to use the constructor with empty parameters, you must write it out explicitly)
// Assign values ​​by set method and constructor respectively

9. What is the meaning of this keyword? How to use
this keyword: A reference to the current object
In most cases, it is used to solve the phenomenon of the same name of incoming parameters and member variables.
You can use this keyword to call other objects in the current class The constructor of this();
10, what does the static keyword mean? How to use it?
static: static, can modify variables (member variables, methods, classes)
Modified variables:
static modified variables do not exist in stack space and Heap space exists in the data area
No matter how many objects are instantiated, all objects share a
static modified variable. When accessing, they do not need to be instantiated, just take the class name to point it out

Modified method:
use, use some tool classes
because it does not require instantiation, it is more convenient to use
Note:
static modified methods cannot access non-static members!!!
11, Introduction to Singleton Pattern
12, Use of Documentation Comments

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325302528&siteId=291194637