1. An abstract class can have a non-abstract method, and all the abstract methods of the parent class must be implemented in the subclass of the abstract, with at least one empty method body.
2. Interface is a special abstract class, the method in the interface can not contain the method body, the default modification is public abstract, can not artificially set the method is private and other modifiers
, but you can specify the method as the abstract method. When a class implements an interface, the methods in the implementation interface in the class must be added with the public adornment.
3. The fields defined in the interface automatically have static and final properties. They cannot be "blank final," but can be initialized to a very few expressions in which fields in the interface can be
Called through an interface (for example: in the main class: System.out.println (Jiekao.value)).
Of course, the field is not part of the interface, but is kept in the static storage area of that interface.
4. Order of initialization:
Class A
Class B extends A
Class C extends B
(1) Load class to memory: General load Class (static) when first used
(2) All objects and class variables are set by default, that is, the object is null and the variable defaults to 0;
(3) Initialization of static methods and variables
(4) constructor: Starting from the parent class. In the same class, initialization of a class variable is preceded by a call to a constructor.
Consider the output of the following program:
Class a{
Private a=11;
Public A () {
Show ();
System.out.println ("This is A struction");
}
public void Show () {System.out.println ("the ' is value =" +a+ ' in Class A ');}
Static{system.out.println ("This are a static in Class A");}
{SYSTEM.OUT.PRINTLN ("This are a clock in Class A");}
}
public class B extends a{
Private a=22;
public static void Main (String arg[]) {
New A ();
A test1=new B ();
b test2=new B ();
}
Public B () {
Show ();
System.out.println ("The B struction");
}
public void Show ()
{System.out.println ("the A Is value =" +a+ "in class B");}
Static{system.out.println ("The Static in Class B");}
{System.out.println ("the Clock in Class B");}
}
The scope of 5.math.random () is: [0,1)
6. When a float or double is formed into an integer value, the fractional part is always "chopped off" without any rounding. For example: Char a= (char) (1.4+ ' a ') has a value of ' B ';
7.16 (Base)--0x octal (base 8)----0;
Bitwise operator ~ for + number sign bit first and then add 1. such as: ~3=-4; for-number sign bit counter then minus 1. Like ~-2=1
8. Shift Operators
The arithmetic object that the shift operator faces is also the binary "bit". You can use them individually to handle integer types (one of the main types). The left shift operator (<<) can move the left side of the operator
Calculates the number of digits specified on the right side of the left move operator (0 in low). The "signed" Right Shift operator (>>) moves the operation object to the left of the operator to the right of the operator to the right
The fixed number of digits. The "signed" right shift operator uses the symbol extension: If the value is positive, insert 0 at the high level, or 1 in the high position if the value is negative. Java also adds a "
The unsigned Right shift operator (>>>), which uses "0 extensions": Inserts 0 at the high level, whether positive or negative. This operator is not in C or C + +.
9. The garbage collection mechanism design plan:
Reference counting scheme, adaptive (Adaptive) garbage collection scheme--stop-and-copy (stop-copy mode) and Mark-and-sweep (Logo-sweep mode)
10.java has 4 access control characters: Public,package (default), Protected,private class has only two access control permissions: Public,package (default), class cannot be private or
Protected
11.singleton design mode:
public class A
{
Private A () {}
Private static A a=new a ();
Public A Geta ()
{
return A;
}
}
12. The loading of a class usually occurs when an object of this class is first created, but is invoked when the static data or static method is accessed.
13. Method overload Way:
The type of the parameter is different from or in the same order.
Note: The overload of the method is determined by the return value only, and the compilation does not pass.
14.abstract and Interface:
Interface only provides form, not talk about realization:
Data members in interface are inherently public static and final, and methods are public by default, and of course defining interfaces or classes in a class can be decorated with a private modifier.
interface allows multiple inheritance (interface a extends b,c{} b,c is an interface);
15. Static methods, static properties, or static inner classes (that is, nested classes) are not allowed in normal inner classes.
The. Class name after compiling in 16.java:
such as: Class a{
Class b{
Class c{}
}
public void F ()
{
Class d{}
}
Public E Gete ()
{
return new E () {
};
}
}
Interface e{}
The. class files obtained after compilation are: A.class,e.class,a$b.class,a$b$c.class,a$1.class,a$1d.class