I. Basic knowledge: a. The class member variable will be initialized. The local variable must be manually initialized. B.Main method must be static, and the return value must be Void, and its parameters must be a string array. At the same time, the method can be overloaded. c. Note the basic data type value range. D. Variable name Name. If you must start must be _, $ and letters. F.GC mechanism. II. Operators: a. logic judgment. Short circuit logic &&, || And the left and right must have a Boolean type. And the value of the left and right can be int, boolean, char. B. >>, << and >>> difference C.3 / 0 will throw an exception, and 3.0 / 0 displays NaN, and 8.0% 2 is taken by an 8.0 cycle reduction 2.0 existence method. At the same time, NAN cannot be compared, only the IsNan method can be compared. D. Var1 var2 "" var2 =? The first (var1 var2) e. == Basic type is relatively small, the reference type comparison address (also clock problem) .Equal () method compares its value. Note that StringBuffer does not rewrite the Equal method, so forever Returns to false. This is because the address indicating the comparison object is returned. F. = Operator connection string. The left must be a string g. ~ You can use the negative reduction. 即 ~ i = (- i) - 1;
3. Java modifier: A.Final, Abstract B.Native, its correct definition method is public native void test (); c. Local variables within methods cannot be static d. The call for non-static methods is determined by the runtime. The call to the static method is determined in the editing period. E. E. External Class Access Internal Class Requires External Class: If OuterClass.innerClass Inner = New OuterClass (). New InnerClass (); f.synchronized can only modify how the method and code block .native modification method does not have a method. TRANSIENT can only modify the variable, indicating that it is not serialized. G.Static I = 100 class member variables can be accessed with this.i.
IV. Type conversion and shape: a. Char -> int -> long-> float -> double byte -> short -> b.byte x = 5; byte y = x << 2; Edit an error, because it converts X to int << 2 to put it in BYTE. C.FLOAT F = 1/3. Because of its 1/3 result, the above expression is correct V. Control program process: A. Break, Continue pair Label B.Boolean M = true; if (m = false) System.out.Println ("Result 1"); Else System.Out.println ("Result 2") Since M is = assignment is false, the print result is performed 2 c. Exception processing try {throw new exception ()} catCH (Exception E) {system.out.println ("Result 1");} Finally {System.out .println ("Result 2");} system.out.println ("Result 3");
Since Catch and Finally do not return. Once print all results D. The label must be e. The thread capture exception is InterruptedException f. If there is a throw exception, but the method has no abnormal statement, and it is added to TRY / CATCH An error will still be compiled. 6. Objects and classes: (Overriding override overloading overload) a. The exception thrown when the rewriting method is defined, only the abnormal subclass or the same. Or do not thrown Any exception. B. A static method can only be overloaded as a static method, and cannot be overloaded as a non-static method. Similarly, non-static methods cannot rewrite static methods. C. Internal classes cannot be with the same name with the external class. At the same time, pay attention to whether the parent class has a default constructor to allow inheritance. At the same time, it is not possible to have a modifier in front of the internal class in the method. D. The constructor does not have a return value. Otherwise, for ordinary methods. E. Internal class definition in block You can only access the final type variable in the block. At the same time, the internal class definitions can access all properties of their class, including private properties. But define internal classes in a method. The access scope is limited to Method body. At the same time, it is also necessary to create an external class. Such as: Class a {public int x; private int y; class b {protected void method1 ()} class c {private void method2 () {}} // End class c} // end class b} // end class A Method2 method can access the Method1 method in the X, Y, class B in Class A. f. Full Package Class Info all member variables are defined as Private, and will be accessed The method of these variables is defined as a non-private type, which can indirectly access these variables outside of the class. G. The parameter list between the method when the overload must be different, and the different factors that determine the parameter list is the number of parameters, order. H When compiling the Java code, if there is an internal class, first package the name of the class. Then follow one $, follow the name of the internal class. If an anonymous internal class, the compiler will simply generate a number. Take them as an internal class identifier Use, then couple the following. I. Static member variable initialization takes precedence over other class member variables. J.CLASS PARENT {void method1 () {s YSTEM.OUT.Println ("Parent's method1 ()");} public void method2 () {system.out.println ("Parent's method2 ()"); method1 ();}}
Public class hello extend1 () {system.out.println ("Child's method1 ()");} public static void main (string [] args) {parent p = new hello (); p.Method2 ( );}} The result is Parent's method2 (), Child's method1 (); but transform the Method1 method in the parent class into private void method1 (). Parent's method2 (), parent's method1 (); k. Interface defined in the interface The variable is final, so it is no longer changed. Seven.java thread: a. Create a thread, one is to inherit the Thread class, the other is to implement the runnable interface. All must define specific threads in the run () method. Perform the function. The start () method only makes the thread from the waiting state to run state. B. Thread state conversion, threads can be interrupted from the execution state to wait for the state or the undo state, the thread is revoked, and the SLEEP causes the thread. In the sleep state. High priority will make the current thread let the CPU usage rights, turn to the waiting state. Or call the input stream read () method will cause the thread to block the waiting state due to invalid data. C. Notify () Methods and WAIT () methods are to achieve a shared lock mechanism. D. Thread exception. When thread is converted from execution status to a waiting state .Wait () method will throw InterruptedException, when the parameter TIMEOUT parameter is taken in Wait When the negative or parameter nanos is exceeded in the range of 0-999999, IllegaLaRgumentException will throw an unmeualarGumentException; if the current thread is not the owner of the object monitor, you will throw the IllegalMonitorStateException exception. E. Thread Resume () method, the method of this method It is a suspended (SUSPENDED) thread that first calls the CHECKACCESS method of the thread, which may result in improving SecurityException on the current thread. If the thread is live (alive) but is hanging (SUSPEND), it is restored and continues its execution process. The SLEEP () method stops the current thread to stop executing, enter the rest Sleeping state, the STOP () method is used to force the current thread to stop execution, but this method has been waped. YiEld () method is used to temporarily stop the currently executed thread. Transfer to other threads. Wait () method is used to make the current thread Into the waiting state. NOTIFY and NotifyAll methods are used to wake up waits.
Eight. User interface components: a. When the component repaint method is called, its default behavior is to call the Update method to re-draw the component. The process of executing the UPDATE method is to eliminate the background. Then call the Paint method to reselect the component. To avoid image flashing Update method, skip clear operation. B. BorderLayout Layout Manager divides the entire interface area into the upper, lower left, right, and 5 regions to accommodate components of the designated area. FlowLayout Layout Manager is based on adding components The order, according to the left to right, from the principle from the top to the principle. GridLayout Layout Manager divides the entire interface area into different grid areas via the specified row, the number of columns into different grid areas, based on left to right, from above The order in the next order is arranged in the network; the CardLayout Layout Manager arranges the component in different "card containers", which overlap each other, only one can be displayed at a time, but the title can be displayed simultaneously in order to activate the corresponding container The GridbagLayout Layout Manager is arranged by the GridbagConstraints object associated with each component. The C.applet calls the getParameter method to get the specified parameter value, but its return value always uses a string as a return value, so in order to get the correct The parameter value needs to be converted. D. D. is the method defined in all event listener interfaces in Java, which returns to Void. E. In the applet, if there is only one component instance, you add multiple adds to INIT However, only the last addition statement is valid. Such as: import java.applet. *; Import java.awt. *; Public class test extends applet {Button Okbutton = New Button ("OK"); public void init () {add ( Okbutton; add (okbutton); add (okbutton); add ("cancel"); add ("Cancel")); Add (New Button ("Cancel")) Add (New Button ("Cancel");
Setsize (300, 300);}} Only 5 Button, 4 Cancel, 1 OK are displayed on the screen.
Nine. Input and Output: A.randomaccessFile If the file does not exist, the file does not exist without throwing the filenotfoundexception exception, and a new file will be created. It only has two access mode. R (read-only) mode , RW (read / write) mode. b. Write the basic data type to the file: import java.io. *; class write {public static void main (string [] args) {file file = new file ("temp.test") ; FileOutputStream stream = new FileOutputStream (file); DataOutputStream filter = new (stream) DataOutputStream; for (int i = 0; i <10; i ) filter.writeInt (i);}} c.ServlerSocket, Socket based on TCP / IP client / server connection. DataGrampacket, DataGramsocket implementation UDP
Ten. Language pack and Package: A.Collection interface defines 15 methods: Add (Object O); Addall (Collection C), Clear (), Contains (Object O), ContainSall (Collection C) Equals (Object O) , Hashcode (), ISEMPTY (), ITEARATOR (), Remove (Object O), Removeall (Collection C) Size (), ToArray () and Toarray (Object [] a); b.map is A collection that supports keyword retrieval, but the keyword must be unique .Set is a collection class that is in order, reject duplicate, List is a collection class with sequential and allowed repetitions, Collection is the root of all set clauses Interface .Enumeration implements a collection class that sequentially access elements. LINKEDLIST collection class. The set class implements the List interface, allowing elements to be added, deleted, or sorted in any location in the collection. So the queue and stacks can implement such . C.Vector class is used to store objects and cannot store basic type data. D. When adding repeated new items to the SET collection, the return value is false, but it will not throw an exception. E. Package class is untrovenial One is created, its content is no longer changed. F.float f4 = integer.min_Value; // min_value = -2147483648 Float F5 = integer.max_value; // max_value = 2147483647 float f6 = -2147483655f; system.out. Println (Math.Round (F6)); due to F6 less than min_value, returns min_value; g.Boolean b1 = new boolean ("true"); boolean b2 = new boolean ("true"); boolean b3 = new boolean (" "); System.out.println (" " b1 b2 b3); its result is Truetruefalse. If printing," ", it will compile errors. H.floating / double value size is: -infinity-- > NE Gative NumBers / Fractions -> - 0.0 -> 0.0 -> Positive NumBers / Fractions -> Infinity Autipsicament: 1. What is the following correct identifiers? A._CLASS; B. $ VALUE $; C .zer @; d. ¥ ngstr; E.2MUCHUQ;
2. What is the following code? Public class test {public static void main (string "args) {string space =" "; string composite = space " Hello " Space Space; composite.concat (" world "); string trimmed = composite.trim () System.out.println (TrimMed.Length ());}} A.5; B.6; C.7; D.12; E.13