ExamBasic Concept

xiaoxiao2021-03-06  81

Java certification brilliance

1. Switch can only be Short, int, char, byte. 2.IF (a = "a") compile error, if (a = false) compiles OK because A = false A represents a boolean value 3. This method Outer.inner i = new outer (). New inner (); ok! 4. File, 8 default is int, 8.0 default is Double 5. Octa is 0 start, not O (English o) 6 .byte -128 ~ 127, -128 What is binary? 7. -1 >> 32 or -1, -1 >>> 32 Why is -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. Compilation is ohat! 10.java default IMPORT package What? classes and objects (class and Object) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0. The outermost class can declare to Final: "$ file a": OK !, but can't be private and static. 1.OverLoad is the same method name in the same kind, Override is the inheritance of the father and son 2.Override's return results must be the same, otherwise the compilation is wrong. The return type of an overriding method IS Identical to the return type of the method it overrides. 2. Override's Modifier can expand, but it cannot be reduced. For example, parent private void test () {} subclavance: public void test () {}, no problem; if it is, It is dead! 3.super.super (), relying on, wrong, no such write 4.static and non-Static never can't override! 5. Look Program PUBLIC CLASS A {void Test1 () throws baseex { Hi ();} void hi () {system.out.println ("SA Y Hi, A ");}} class aa extends a {void hi () {system.out.println (" Say Hi, AA ");}} Class test {static void main (string b []) throws exception { A a = new aa (); a.test1 ();}} The result is, "Say Hi, AA", what? Description, the method will always follow the original face of the class; and the variable is just the opposite! 6. One Non-abstract methods, don't want Override to become an abnormality of a subclass of an abstract method 7. The abnormality thrown by the subclass of Override can only be a parent class to throw an abnormality class, or there is no! 8. The constructor cannot be native, Final, static, synchronized, can be public, private, nothing, huh, huh 9. Write returni in the constructor, but nothing is there, even NULL (this is not nonsense, haha) 10. The constructor cannot return a value. This one knows, but if there is a "constructor", it is not tension, it is not a constructor, just a normal function 11.super (); this (); these two The function can only be called in the constructor. 12, the member variable declares when it is assigned, and the constructor is also early .int i = 1;

Ealier THAN TEST () {} 13. The parameter variable of the method can be final. 14. hashcode Returns an int 15. void wait () throws interruptException Wait throwing interruptException is not a VoID package 17. Byte , Interger, Double ... all the number of copies related packaging classes are inherited in the Number interface interface "~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. All methods of the interface are public, Abstract and Non-Static 2. All variables of the interface are public, static, final. So, the variables of the interface cannot be changed, in its implementation class. 3. Implementation of the interface implementation must be implemented and interface The method throws the same exception, which is not a subclass, which is different from Override! Similarly, if the interface method does not throw, implement the method can not be thrown. 4. Implementing the way to implement the implementation must be explicitly declared into public, what Don't write, ah !!! 5. The interface can't declare into final, do you want it to be implemented? 6. A class implements two interfaces, if the two interfaces have the same way, implementation Class to achieve this method, no problem. Inner Class) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Embedded categories can access any variables of the Outer class, including private. 2 . Static Inner class, only any STIC variables that can only access the Outer class 2. The embedded category can be Final, Abstract 3. **, the inline category within the method cannot be static: void test () {static class a {}} XXXXX !!!! 4. **, the inline category within the method can also bring any modifier, void test () {public class a {}} xxxxxx !!!! 5. **, the inline category within the method only Access the final variable in the method, however, you can access any variables of the Outer class. 6. Anonymous classes do not have a constructor, but declare the parameters, equivalent to the parameters of the constructor. Class ABC {} Class AB Cd {private abcd ({}) {return new abc () {} abcd test4 () {RETURN NEW ABCD (3) {};} interface III {} III TEST5 () {Return New III () {};} // Class BCD Extends ABCD {} Compile Error, because, look at the new iii () {}; actually anonymous class implementation III interface; new ABC () {}; actual The anonymous class inherits ABC. 8. ??? Class A {Private A () {system.out.println ("a!");}} Class B Extends a {} **, yes! B instance When you take the initiative to call the texture of the parent class A, even private, it seems no problem !!! 9. Internal classes can have a synchronized method, then the lock is this internal class, there is no relationship with the external class, inside and outside, On the problem of lock. 10. External classes cannot be accessed through this, this should refer to the internal class at this time, and the members who enjoy the external class are directly used, do not add any qualitative words 11. How to use this? Please see: Class Outer {INT I; Class Inner {Class Innerinner {Void Test () {Outer.THIS.I = 1;}}}} See you, class name .this. Variable name, you can quote i, for the first time Let's go, 嘿嘿, 闻. 12. Note that these two ways can be class outer.inner i = new outer (). New inner (); or, class o =

New outer (); class outer.inner i = o.new inner (); thread thread) ~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ????? Go see Thread's API !!! ! 1. Thread startup must pass through the start function. 2.Run function is allowed to be public. 3. Thread has priority from 1 to 10, via thread.SetPriority (int); can not exceed 10, otherwise Operation exception 4. Thread priority is 5, namely norm_priority.????????norm_priority is a static variable of Thread? 5. ???? thread.yeild (); is a static method, so use The format is thread.yield (); she is forced the current process to give up Cup. 6.sleep (1000), is a thread to sleep for 1 second, then enter the resty state, pay attention, not the operation, it also wants to wait for OS to schedule Get Cup. Java.lang. *; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~, Cologne: INT IA [] [] = {{1, 2}, null}; int} [] [] = (int [] []) ia.clone (); 2. What is Nan ????? then CEIL (NAN), Floor (NAN), ... 3.math.floor (- 1.1F); // - 2.0 math.ceil (-1.1f); // - 1.0 Math.Round (-1.6d) // - 2 4.0 = 5.Math, Interger, Boolean ... and other types of packaging classes It is final, not inherited 6.int runk (float); long round (double);, Round will always return a decimal point 7.Static Double CEIL (Double) 8.Static Double Floor (double) Note, CEIL, Floor is only This double version is turned to Double! 9.Static Double Sin (Double Recrens); there is COS, TAN 10. New String;? Can be Byte [] CHAR []; string; StringBuffer 11. Some functions of String: intlength (); char charat (int); string Touppercase (); string tolowercase (); 12. String ("abc"). Equals (String). ABC ")) is not equal, otherwise there will be no boolean equalsignorecase (String) function 13." 012345678 "is a series of sequential numbers, indexof ('1'), indexof (" 1 ") Returns 1, Substring 1, 5) is 2345, 嘿嘿: Yes "[)" feel 14, Trim () even Tab is retreat, "/ t / n java", Trim () only "Java" 15. About Cologne, go to API ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 16. "ABCD" New String ("EF") It is a reasonable way of reading 17. StringBuffer 3 constructors: () initialization capacity is 16, (int initialization capacity), (String), initializing capacity is a string length plus 16 18. Some functions of StringBuffer: String toString () , append (); Reverse (); INSERT (); delete (int start, int end); deletecharat (int);

SETLENGTH (INT NewLength); 19. String S = ""; StringBuffer SB = New StringBuffer (); if (s == SB) {} Compilements! Because, S, SB type is different, can not compare the collection: 1. Each The relationship between the interface and class, only the last one is class Collection: list: Vector, ArrayList, LinkedList Map: SortedMap: TreeMap Collection: Set: Sortedset: Treeset Map: HashTable Collection: SET: Hashset Basics Base) ~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ 1.java Application's main may not be public. But must be static's 2. A file can only have a public class, but also to follow the file name, including case 3. Variable Can only be letters, $, _ beginning, the next second can be, number 4.ch/u0061r='a '; char / u0063 =' b '; char c =' / u0063 '; all legal 5.1e-5d, legal .E-5D is not legal, there must be the previous coefficient 6.int [] i [] = {null {1, 2}} correct! Int i [] = {1, 2, 3,} Correct! "," And no effect is 7. Local Array, like variables, to initialize 8.main method can be Final Operators and Assignments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ 1.System.out.Printl (1 2 "3"); // 33 System.out.printl ("1" 2 3); // 123 2.int i = 0 i = i ; i = i ; I = i ; result, i = 0! 3.int i []; index = 0; i [index] = index = 5; result, i [0] = 5 ;! !! 4.byte b = 10; can, because 10 can be automatically transferred from int to BYTE 5. Next, byte b = b 10; can not !! Because, 10 b after I NT cannot be automatically transferred from int to Byte, ask me, I don't know why! By! 6.byte b1 = 4; BYTE B2 = 6; B1 = B1 B2; wrong! After compiling the wrong! B1 B2, must Forced to BYTE, B1X1 B2); 7.XOR is 0, not the same as 1 1, 1 = 0; 0,0 = 0; 1, 0/0, 1 = 1 8. x == float. NAN compiles, it should be float.isnan 9. x == double.positive_infinity compile can be 10.-1 is 1111 .... 1111, << Forever right to make up, >> 正 正, negative one, >> > Hengsui zero 10.1 -1 >> How many bits are -1; 1 << 31 becomes minimum negative number, 1000 .... 0000 11. The maximum positive number is 01111 ... 1111 12. Minimum negative number is 1000 .... 0000 (-2147483648) 13. A InstanceOf B, B must be class / interface,

Can't be an example -------- Add ---------------------------- 1. Byte, Short, Char There is a var = -var; compile errors, because the -var at this time is 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 && B4 == b5; b1 = b2 == b3 == True is all right! B1 = B2 == B3 == B4 xxxxxx compilation! 6 1 >> 1 is 0 7.% = << = = >> = >>> is a legal symbol 8. --1-10 * 4 This way is correct, that is, (--1) -10 * 4 9. k = 1; k k ; result is 7, equivalent to ( 2) (2 ) ( 3) 10. Number cannot be marked. Hi: if {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 {} Oh, main can throw out an exception 12. Hi: if (b == true) {Break hi;} Break label, can be used in IF. Other no, including Break, Continue label. 13.int x = i * -J; **, 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 the difference???? ??? About outsourcing can access the sub-class access? 4. After the member variable is modified into final, it must be declared to assign initial values ​​or assign initial values ​​in the constructor, don't counting she can get the default value. 5. Abstract method can be static!!! 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 (); // Hi, Parent! 7 The static method can be called by an instance of the class. New child (). Test (); and child.test ();

Both OK! 8.Transient can only be used on a member variable of class, cannot be used in the method. 9.Transient variables Can't be Final and Static 10.native method can be private, abstractd flow control ~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ 1. The statement that is not arrived is wrong: while (false) {}; for (; false {}; if (false) {} can't compile 2.FOR (Part 1; The first part can be used to declare or assign a value, but it cannot be both 3.Byte B; switch {case 200: // 200 Not in Range of Byte, because 200 exceeds B range, compiling errors 4. Continue with label Go back to the position of the label, from the newly entered the loop 5 after the label 5. Break with the label interrupt the current loop and transfer to the end of the loop of the label, converting and casting ~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ binary Operators Convert the smaller (less precise) Operand. All operators Will Convert Things Smaller Than INTS TO INTS or LARGER. THIS INCLUDES CHAR 'S ! 1.byte, char, short defaults to int 2.Byte-> short-> int-> long-> float-> DoubleChar ^ This is the default can be transformed in the direction, but it must be explicit Cast! Special attention: Long-> float is the default, don't look at long64, float32, and it is to see, can't be converted to each other between 3.float f = 1/3; OK! float f = 1.0 / 3.0; Compilation error, because 1.0 / 3.0 result is Double, oh ~, wrong !! 4.. = 1; Byte B = i; wrong! Need explicit CAS t. Final i = 1; Byte B = i; just ok! I don't know why, final can. And, according to my experiment, INT and BYTE relationship, other can't. 5.int i []; object [ ] obj = i; wrong! Object obj = i; 对! Arrse can only turn into Object, not Object [] 6.int i []; object [] obj; i = (int []) OBJ; Objects can be transformed into an array through explicitly. I / O ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. There are some important methods of the File class: isFile (); isdirectory (); string [] List (); exists (); getabsolute (); getParent (); 2. Through Delete (); mkdir (); rename (file newname); can manipulate files, but change the content of the file 2.1 File class cannot change the current Directory unless a File object is recreated. 3.NPutStream In, String EncodingName; OutputStream In, String EncodingName;

转载请注明原文地址:https://www.9cbs.com/read-120498.html

New Post(0)