1. When the object is passed as a parameter, the address value is passed
When an object is passed into a method as a parameter, the address value of the object is actually passed in.
2. The difference between local variables and member variables
3. Super keyword usage
- In the subclass member method, access the parent class member variable;
- In the subclass member method, access the parent class member method;
- In the subclass construction method, access the parent class construction method;
4. Usage of this keyword
- In the member method of this class, access the member variables of this class;
- In the member method of this class, access another member method of this class;
- In the construction method of this class, visit another construction method of this class;
5. Single inheritance
Java is single inheritance, and there is only one direct parent of a class. Only one class can be followed by extends.
Can be inherited at multiple levels:
class A{
}
class B extends A{
}
class C extends B{
}
6. Abstract class
Abstract class:
public abstract class Animal{
public abstract void eat(); 抽象方法
public void jiao(){
普通方法
}
}
Abstract classes cannot create new objects;
there must be a subclass that inherits the abstract parent class; the
subclass must cover all abstract methods in the abstract parent class;
create subclass objects;
public class Cat extends Animal{
@Override
public void eat(){
System.out.println("猫吃鱼");
}
}
An abstract class can have no abstract methods, as long as the class with abstract methods is an abstract class.
An abstract class without abstract methods cannot create new objects. This class has special uses in design patterns;
7. Interface
The interface is a common standard.
As long as it meets the standard, it can be used universally.