Super keyword
Represents the parent class object.
1. You can call the overridden method in the parent class.
2. Also call the constructor method in the parent class. Placed in the first row of the subclass construction method. Cannot appear at the same time as this keyword.
Final keyword
1. Modifier properties. Represents a constant. The amount that cannot be changed. The definitions of constants are all capitalized. Example: publicstatic final int num=20;
2. Modification method. Indicates that the method cannot be overridden by a quilt class.
3. Modifier class. Indicates that the class cannot have subclasses. For example, theString class.
instanceof Keywords
Application format: Object name instanceof class name returns a boolean type value
Effect: Determines whether an object is an instance of the class.
Abstract class
There is a class in Java that specializes in parent classes.
Classes that use the abstract adornment are abstract classes.
Abstract methods: Methods that use the abstract adornment and do not have a method body. Abstract methods must be placed in an abstract class. Example: Publicabstract void Fun ();
Features of abstract classes and abstract methods:
1. All are decorated with the abstract keyword.
2. There is no method body for abstract methods. {}
3. The abstract method must be placed in an abstract class.
4. An abstract class cannot instantiate an object.
5. An ordinary subclass inherits an abstract class, and the subclass must override all abstract methods in the abstract class.
interfaces (which can be understood as rules or rules)
1. Prior comprehension:
An interface is a special kind of abstract class.
Because all methods in the interface are abstract methods and global constants.
2. Define the interface.
Interface interface Name {
public static final: Modifier attribute member//global constant
Public Abstract: Modification method//abstract method
}
These are fixed formats, so you can omit them.
3. Interfaces cannot be instantiated either. The interface can be implemented by the class (keyword implements), and a class can implement multiple interfaces.
4. A class must inherit a parent class and implement multiple interfaces.
public class class name extends parent class name implements Interface 1, interface 2 ... {
}
5. Interfaces can inherit interfaces. and support multiple inheritance.
Interface A extends B,c,d ... {
}
Java Basic Note 9