It 18 Palm Fifth day summarizes class member variables, property member functions, methods. Constructors-------------have the same name as the class. no return value. JavaBean Specifications------------------Private properties, public getter/setter. code block----------------1. A local code block defines {} inside a function and cannot use the static adornment. 2. Constructing code blocks is also a member of a class, and member variables and member functions are siblings. When constructing an object, the construction code block is called first and then the constructor. 3. Static code block constructs code block + static modifier. A static block of code executes when the class is loaded and executes only once. Manual control class loading uses Class.forName ("ClassName"), which executes the code block when the class is loaded by default. Class.forName (String,boolean initialize,classloader) controls whether the initialization occurs when loading. Inheritance when the same properties and behaviors exist in multiple classes, the content is extracted into a single class, so that multiple classes do not need to define these properties and behaviors, as long as they inherit that class. multiple classes can be called subclasses, and a separate class can be called a parent class or a superclass. The subclass can directly access non-private properties and behaviors in the parent class. enables inheritance between classes and classes by extend keywords. class SubDemo extends Demo {} Let Class B inherit Class A The advent of class B extend A { ...... } inheritance has improved the reusability of code. The advent of inheritance has created a relationship between classes and classes, providing a precondition for polymorphism. Inherited features java support for single inheritance only, multiple inheritance     &NB not supportedSP; A class can have only one parent class and cannot have more than one parent class. class a {} class aa {} class b exdents a {} class c exdents a ,aa //error java supports multilayer inheritance class a {} class b exdents A {} class C exdents B {}Super The use of super and this is similar to this, which represents a reference to this class of objects super the identity of the memory space of the parent class. when a child parent class has a member of the same name, you can use super to differentiate subclass to call the parent class constructor, you can make a super statement. in this class super (); calls the constructor of the parent class super. Call the parent class's method this. call other methods of this class this () call other constructors of this class this () super () The constructor must be the first line this . super. can be called anywhere All constructors in a subclass access the constructor of the parent's hollow argument by default when the constructor for the parent class does not have an empty argument, the constructor of the subclass must specify the constructor to be accessed through this or the super statement. The subclass overrides permissions greater than the parent class's method permissions (permissions can be magnified and cannot be scaled down (not privatized)). final --------------- modifier class, means class cannot be inherited adornment method means the method cannot be modified Private method can use final can compile but meaningless final the modified variable is a constant. Can only be assigned once. (if not assigned, compilation fails) abstract abstract ------------- 1. method without method body, must use abstract to decorate 2. Abstract methods can only exist in abstract classes 3. Abstract classes must also use abstract adornments. 4. abstract classes do not necessarily have abstract methods 5.abstract+static are illegal modifier combinations final+ abstracr illegal modifier combination private +abstract is an illegal modifier combination 6. Interface-oriented programming to reduce coupling (ease of maintenance) enhanced extensibility abstract method only method declaration, no method body, first in abstract class format: modifier abstract range value type Function name (c parameter list), abstract class can not be instantiated, cannot be new create object abstract class is the concrete thing extracted, itself is not concrete, no corresponding instance. abstract class Even if an object is created, invoking an abstract method is meaningless. Abstract classes are instantiated by subclasses. the subclass must completely overwrite all abstract methods in the abstract class to create an interface interface--------------------format The member modifiers of the interface {} interface are fixed member variables:public static final (constants) member functions:public abstract the members in the Discovery interface are public interface allows inheritance interfaces allow multiple inheritance classes and interfaces are implementation relationships *. Text describes the role of static code blocks. A : static code blocks are executed when the class is loaded and executed only once. can customize the execution of static code snippets *. 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? The a: sequence is constructs a code block --> constructor  , and is independent of the declaration position of the method. is also a member of a class, and a member variable and member function sibling. The main purpose is to improve the reusability of the code and initialize the member variables. *. Will the static code block be executed when the class is loaded? How do I manually control class loading? A: Class load is the default is to automatically load the execution of static code blocks, manually control class loading using Class.forName ("classname"), the default load class, execute code block. *. Define the class Person,man,woman to form an inheritance relationship. A:/*** extends format : class B extends A {} B-->A */class  person { //definition person class } class man extends person{ //let man class inherit Person } class woman extends person{ }*. What is an abstract method? What is an abstract class? Do abstract classes have constructors and can they be overloaded? a: Abstract method is must use abstract to decorate the method without a method body must have subclasses to implement the "class containing the abstract method is the abstract class must also be decorated with abstract ." abstract classes have constructors can also be overloaded *. What are the illegal combinations of abstract modifiers? and give a reasonable explanation? A:abstract+static static modifies the properties of a public class, and abstract direct access is meaningless. final+abstracr final Is the final cannot be changed, and abstract is required to instantiate the subclass, it needs to be manipulated. private +abstract privatization cannot be inherited, Abstract is the *.super and this role and usage as well as considerations that require subclasses to instantiate? The use of A:super super and this is similar to this for references to this class of objects super represents the identity of the memory space of the parent class. &nbSP; When a member of the same name appears in the child parent class, you can use super to differentiate subclass to call the parent class constructor, you can make a super statement. in this class super (); calls the constructor of the parent class super. Call the parent class's method this. call other methods of this class this () call other constructors of this class this () super () constructors must be the first line this . super. can be called anywhere * . Define interface 1. IWhite2.IRich3.IBeanti4. Define a class to implement the above three interfaces. (Womenstar) 5. Define the Local Tyrants class (Earchricher.marring (...)) The format of the/*** interface interface is: interface {} *///definition of three white, rich, beautiful interface iwhite{ //definition white public void whiteing (); }interface irich{ //definition Rich public void riching (); }interface ibeautiful{ //definition Beauty public void beautifuling (); }//defines an interface inheritance white, rich, beauty Three interfaces interface womanstart extends iwhite,irich,ibeautiful{}//define local tyrants class CLASS&NBSp earchricher{ // public void marry (WomanStart MM) { system.out.println ("find mating !! "); }}class earchricherman { public static void main (String[] args) { womanstart w = new womanstart () {public void whiteing () { }public void riching () { } public void beautifuling () { }}; earchricher m =new earchricher (); m.marry (W);}}
It 18 Palm Fifth day course summary (including assignments)