1. Text describes the role of static code blocks.
2. What is the order in which the code blocks and constructors are called? is the declaration position of the method relevant? Why? What is the purpose of building blocks of code?
3. Will the static code block be executed when the class loads? How do I manually control class loading?
4. Define the class Person,man,woman to form an inheritance relationship.
5. What is an abstract method? What is an abstract class? Do abstract classes have constructors and can they be overloaded?
6. What are the illegal combinations of abstract modifiers? and give a reasonable explanation?
7.super and this role as well as usage and precautions?
8. Defining the interface
1.IWhite
2.IRich
3.IBeanti
4. Define the class to implement the above three interfaces. (Womenstar)
5. Define the Local Tyrants class (Earchricher.marring (...))
----------------------------------------------------------------------------------------------------
A code block is one of the constituent components of a class, and member variables, member functions, inner classes, and parallel components together. Static code blocks are executed only once when the class is loaded.
Constructing a block of code is called before the constructor, regardless of the location of the declaration, relative to the constructor function. The purpose of building blocks of code: 1, to promote the reuse of code, you can say each constructor of the same code extracted. 2 Initializing objects
Static code blocks are not necessarily executed when the class is loaded. The default way is to execute. If you are invoking a class object as a Java reflection mechanism, you can manually choose to load or not load. Class.forName ("Class name", whether Boolean is loaded);
Class Person
{
}
Class Mans extends Person
{
}
Class woman extends person
{
}
There is no method body for abstract methods. Abstract classes refer to classes that have abstract methods. The Java tutorial says that abstract classes have constructors that can be overloaded
Private abstract is illegal and cannot be overridden if it cannot be inherited.
Abstract final is illegal, final cannot be modified, cannot be modified and cannot be overridden by inheritors
Abstract static is illegal, static is statically at the time when the class is loaded, it is convenient to access directly with the class, abstract no meaning, access is invalid
Super is a pointer to a superclass object, this is a pointer to this object. Super () The default appears in the first row of all object constructors to represent the creation of superclass objects. Super (..) And this (..) Can only be used in the first row of the constructor, and only two is selected.
Interface Iwhite
{
}
Interface Irich
{
}
Interface Ibueaty
{
}
Interface Iall extends Iwhite,irich,ibueaty
{
}
public class Womanstar implements iall{
}
Class earnricher{
public void Marry (Iall woman) {
}
}
public static void Main (string[] args) {
Womanstar star=new Womanstar ()
New Earnricher (). Marry (Star)
}
Static code blocks, class inheritance, and interfaces