Java Certification Summary 1. Switch (?) Can only be short, int, char, byte. 2.IF (a = "a") compile error, // assignment operation IF (a = false) Compile OK, reasons Is a boolean value of A = false 3. This way of writing Outer.inner i = new outer (). New Inner (); ok! 4. File, 8 default is int, 8.0 default is Double 5. Okiminary It is 0 beginning, not O (English O) 6.byte -128 ~ 127, how much is binary? 7. -1 >> 32 or -1, -1 >>> 32 Why is it -1? 8.char C ='c'; string s = "s"; s = C; result is SC !!! 9.Boolean b1 = true; boolean b2 = true; system.out.println (b1 | b2); result is true. Compile! 10. Java's default IMPORT package ??????? java.lang. * Class and objects (class and object) ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 The outermost class can be declared as Final: "$ file a":
If the parent class's Hi () declares is Private, "Say Hi, A" is output, and the reason is not known, remember is! 6. A non-abstract method, don't want Override to become an abnormality of the subclass of an abstract method 7. The abnormality thrown by the subclass ofoverride can only be a parent class to throw an abnormality class, or there is no! 8. Constructor cannot It is native, final, static, synchronized, can be public, private, nothing, huh, huh 9. Write return in the constructor, but nothing is not allowed, or even null (because it does not return value) 10. The constructor cannot return a value. But if there is a "constructor", it is not tense, it is not a constructor, just a normal function 11.super (); this (); these two functions can only Call in the constructor, and must be in the first line 12. Member variables declare to assign the value than the constructor is also early. INT i = 1; Earlier Test () {} 13. The parameter variable of the method can be Final, no access Control modifier (public, etc.) and static 14.hashcode Returns an int, object's memory address 15.void Wait () throws InterruptException, Wait Throw InterruptException is nothing out 16.java.lang.void is a Void package 17.byte, interger Double ... All the number of copies related packaging classes are inherited in Numeric interface: (Interface) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. All methods of the interface are Abstract by default. No method) and non-static 2. All variables of the interface are static, final, so the variables of the interface cannot change the value in its implementation class 3. The implementation of the implementation of the interface must and the interface method Throw the same exception, not a subclass, which is different from Override! Similarly, if the interface method does not throw, the method cannot be thrown. 4.Runnable interface There is a Run () method, implementation of the implementation method must declare into public void run () {...} 5. The interface cannot be declared into final, do you have to be implemented? (This seems to be nonsense: 6. A class implements two interfaces. If the two interfaces have the same method, implement the class to implement this method, no problem. 7. Interface cannot be instantiated, can only be implemented by the class / interface 8. Interface inheritance interface EXTENDS, class implementation interface with IMPLEMENTS 9. The interface can only be declared as public or default, and there is a modifier Abstract to compile within the front: (Inner Class) ~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Inline category can access any variables of the Outer class, including private 2. Static Inner class, only any Static variables of the Outer class (any static content can only access static) 3. The embedded category can be Final, Abstract 4. The inline category within the method cannot be static, void test () {static class a {}} xxxxxx !!!! 5. The embedded category within the method cannot take any modifier. Void test () {public class a {}} xxxxx !!!! 6. The inline category within the method can only access the Final variable in the method, but you can access any variable of the Outer class 7. Anonymous classes do not have a constructor, However, with parameters, it is equivalent to the parameter transmission of the constructor.
Class ABC {} class abcd {private abcd (int i) {}} ABC test3 () {Return new abc () {} ABCD test4 () {Return new abcd (3) {};} interface iii {} iii TEST5 () {Return New III () {};} // Class BCD Extends Abcd {} compile error, ) {}; Actually anonymous class inherits ABC. 8. Class a {private a () {system.out.println ("a!");}} Class B Extends a {} is right! B is instantiated, I will actively call the texture of the parent class A, even private, it seems that there is no problem !!! 9. The internal class can have a synchronized method, then the lock is this internal class, with the external class, there is no point; On the problem of lock, the inside and outside is separate. 10. External classes cannot be accessed through this, this should refer to internal classes at this time, and the members of the external class are used directly without adding any qualifiers. 11. How to use this? See: class outr {ion i; class inner {class innerinner {void test () {outer.this.i = 1;}}}} is seen, class name .this. Variable name You can quote i, see it for the first time, hey, lonely.
12. Note that these two ways can be Outer.inner i = new outer (). New inner (); or, Outer o = new outer (); Outer.inner i = OU.NEW Inner (); thread: (Thread: (Thread) ) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ ????? Go to Thread's API !!!! 1. Thread startup must pass start () 2.Run () can only be public 3. Threads have priorities from 1 to 10, via thread.setPriority (int); can not exceed 10, otherwise run exception 4. Thread priority is 5, namely Norm_Priority, is Thread's static variable 5 .Thread.yeild (); is a static method, so using the format is thread.yield () or yield (), she is forcing the current process to give up Cup 6.sleep (1000), is a static method, it is said that thread is sleeping 1 second and then enter the Ready state Note: instead of running state ,, it have to wait to get the OS to schedule CUP java.lang *; ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Array clone : int {=} [] = {{1, 2}, null}; int}; INT IB [] [] = (int [] []) ia.clone (); 2. What is nan ???? then look CEIL (NAN), FLOOR (NAN), ... 3.math.floor (-1.1f); // - 2.0 math.ceil (-1.1f); // - 1.0 Math.Round (-1.6d) / / -2 4.0 = ABCD ".trim ()," ABCD " New String (" EF ") is a reasonable write 17. StringBuffer 3 constructors: () initialization capacity 16, (int initialization capacity), (String) initialization capacity Some functions for the string head plus 16 18.StringBuffer: string toString (); append (); reverse (); insert (); delete (int start, int end); deletecharat (int); setLength; INT New " 19. String S = ""; stringbuffer sb = new stringbuffer (); if (s == sb) {} compile error! Because S is different from SB type, no collection: 1. The relationship between the interfaces and classes, only The last one is class Collection: list: Vector, ArrayList, LinkedList map: SortedMap: TreeMap Collection: SET: SORTEDSET: TREESET MAP: HashTable Collection: SET: Hashset Basge: (Base) ~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ 1.java Application MAIN can not be public, not static, successful compilation, but run error 2. A file can only have a top PUBLIC class, but also to the file name, including case 3. Variables can only be letters, $, _ beginning, the next second can be numbers, letters, $, _ 4.char / u0061 ='A'; char / u0063 ='B'; char c = '/ u0063 '; All 5.1e-5D legal, E-5D is not legal, the front must have coefficient 6.int [] i [] = {null, {1, 2}} correct! Int i [] = {1, 2, 3,} Correct! 7. Array (whether or in the class or in the method) does not initialize before use, the variable is different, the class variable is not initialized before use, the automatic variable (defined in the method) before use Must be initialized. 8.main method can be Final operator and assignment (Operator and assignment) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1.System.out.printl (1 2 "3"); // 33 System.out.Printl ("1" 2 3); // 123 2.int i = 0; i = i ; i = i -; result, i = 0! I = i; The result is 1 I = - i; the result is -1 3.int i []; index = 0; i [index] = index = 5; the result is i [0] = 5; !!! 4.Byte b = 10. Because 10 can be automatically transferred from int to BYTE 5. Next Byte b = b 10 can't !! Because 10 b cannot be automatically transferred from int to BYTE 6.BYTE B1 = 4; byte B2 = 6; b1 = b1 b2; wrong! After compiling the wrong! B1 B2, it must be forced to convert (BYTE) (B1 B2); 7.xor is 0, not the same as 1 8. x == FLOAT.NAN compiles, it should be float.isnan (x) 9. x == double.positive_infinity compile can be 10.-1 is 1111 .... 1111, << Forever right to make up, >> 正 正 零, negative Supported one, >>> Hengsui zero-1 >> How many bits are -1; 1 << 31 becomes minimum negative number, 1000 .... 0000 11. The maximum positive number is 01111 ... 1111 12. The minimum negative number is 1000 ... 0000 (-2147483648) 13. A InstanceOf B must be a class / interface, can't be an example -------- Add ------------ ------------------ 1. Byte, short, char = -var; compile errors, because the -var has been automatically turned into an int type 2 . INT / 0 will throw the ArithmeticException Double, float / 0 get inf or -inf 0/0 NAN 3. Int ABC; is a variable name that does not meet the naming rule? 4. CHAR A = ' / u0001'; pair! char b = / u0001; compile error! 5. Boolean B1, B2, B3, B4, B5; B1 = B2 == B3; // b1 = (B2 == B3) B1 = B2 == B3 && B4 == B; // b1 = ((B2 <= b3) && (b4 == b5)); b1 = b2 == b3 == True; // b1 = (b2 == (b3 == True)); b1 = b2 == b3 == b4 is all right! 6. 1 >> 1 is 0 7.% = << = = >> = >>> is a legal symbol 8. --1-10 * 4 This kind of writing is true, that is, (--1) -10 * 4 9. k = 1; K K K; the result is 7, equivalent to ( K) (K ) (k) = 2 2 3 10. Number cannot be marked. Hi: if (b) {Break Hi; // Break Hi1 No, no backward} // hi1: No, you can't put it before INT i; hi1: i = 1; 11.public static void main (string s []) throws exception {} can be, main can throw Outnomial 12. Hi: if (b == true) {Break Hi;} Break label, can be used in IF, other things can not, including Break, Continue label. 13.int x = i * -j; me Rely, no problem !!! Compilation is true! Int x = i * j ; this is no problem, variable modifier (Modifier) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. The outermost layer cannot be declared into protect and PRAVITE 2. The two instances of the same class can access each other's private methods and private variables, cool! 3. Protect and no modifier specific differences ??????? About outsourcing can access the subclass access to which? 4. When the member variable is modified into final, it must be declare that the initial value is assigned or in the constructor. Getting the initial value, don't expect her to get the default value. 5. Abstract method can be static !!! Native method can't be Abstract 6. Static method will change with the change of the class, see example: Class Parent {static void Test () {System.out.println ("hi, parent")};} class child extends Parent {static void test () {system.out.println ("hi, child")};} Parent P = New child ); p.Test (); // is hi, parent! Static method is not Overrided, just hiding differences in situations (output Hi, Child) without statements (Output Hi, Child) 7. Static method can pass class instance Call. New child (). Test (); and child.test (); all OK! 8.Transient can only be used on a member variable of the class, can't be used in the method 9.Transient variable cannot be Final and Static 10 .native method can be private, final, no method body, can not be Abstract, process control ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. The statement that is not arrived is wrong: while (false) {}; for (; false;) {}; if (false) {} can be compiled 2.FOR (first part ;;) The first portion can be used to declare and assign, such as for (int i = 0; i < 5; I ) 3.Byte B; Switch (b) {case 200: // 200 Not in Range of Byte, because 200 exceeds B range, compiling error 4. Tagged Continue to the label location, from new entry Retrieve the loop behind the label 5. Break with label interrupt the current cycle,