Java certification SCJP brilliance

zhaozj2021-02-17  49

Reprinted: Javaunion.org Java Certified Sceill Summary

3. Switch can only be short, int, char, byte. 4.IF (a = "a") compile error, if (a = false) compiles OK because a = false A represents a boolean value 6. This method Outer.inner i = new outr (); new inner (); ok! 7. File, 8 default is int, 8.0 default is Double8. Octa is 0 start, not O (English O) 9. BYTE-128 ~ 127, -128 How much is binary ?????????????? 11. -1 >> 32 or -1, -1 >>> 32 is still -1 ???? ???????????????????????? 12. CHAR C = 'c'; string s = "s"; s = C; the result is SC !!! 13. Boolean B1 = true; Boolean B2 = True; System.out.Println (B1 | B2); the result is true. Compilation is ohatd! ????? Java's default IMPORT package ??????? awt ~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ 1. All component flowLayout will be compressed for their minimum size 2. BorderLayout's North, South, West, East, Center is like this, four word cases are different, must be written, otherwise Wrong ????????? 2.1 If just add, not writing in the northwest of southeastern, default is China 2.2 If you do not add Component, it is empty. 2.3 If a part is a Component, if you still Add Component to the top, later cover the original 3. Applet, Panel default layout is flowLayout4. Frame, Dialog default layout is borderLayout5. All kinds of AWE classes, Frame, Window, Component, ...?????? ?????? 6. Window, Frame, Dialog cannot be embedded in the container. Note: WINDOW! 7. Action Event acts on the return time of Button and TextFeild, 8. Item Event works on List, Choice, Checkbox selection Change time 9. If the container is invisible, the new Layout Manager will follow this new Layout change, if the container is visible, These Components will not affect the later Layout in the 10.GridBagLayout in the greative size of 10.GridBagLayout, and Component can take up multiple grid12.system.exit ();

No calls are not allowed in Applet. AWT event ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Symantic Semantic events: ActionEvent, Adjustevent, ItemEvent, TextEvent Low Event: ComponENTEVENT, ContaineRevent, FocusEvent, InputEvent, KeyEvent, MouseEvent, PaintEvent, WindowEvent2 listener:. ActionListener, AdjustListener, CompentListener, ContainerListener, FocusListener, ItemListener, KeyListener, MouseListener, MouseMotionListener, TextListener, WindwosListener, a total of 11 listener, seven adpter, less 4 It is ActionLisenter, AdjustListener, ItemListener, TextListener, only one way .3, mouse mouselistener has 5 methods: Clicked, Pressed, Released, Entered, Exited4. Mouse MouseMotionListener has 2 methods: mousedragged, mousemoved

Class and objects (Class and Object) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ 0. The outermost class can be declared into 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 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 () {} subclava: public void test () {}, no problem; if it is, Over-tuning! 3.super.super (), relying on, wrong, no such written 4.static and non-Static never can't override! 5. See program public class a {void test1 () throws baseex {hi () void Hi () {system.out.println ("Say 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, method always follow the class The original face; and the variable is just the opposite! 6. A non-abstract method does not want Override to become an abstract method 7. The abnormality of the subclass of the subclass ofoverride is throwing an abnormal child. Abnormal class, or no! 8. The constructor can not be native, final, static, synchronized, can be public, private, nothing, huh, huh 9. Can write return in the constructor, but nothing is not Yes, even null (this is not nonsense, haha) 10. The constructor cannot return value. This everyone knows, but if there is a "constructor", don't be nervous, it is not a structure造, just a normal function 11.super (); this (); these two functions can only be called in the constructor .12, member variable declare time assignment, the constructor is also early .int i = 1; elier THAN TEST () {} 13. The parameter variable of the method can be final.14. Hashcode Returns an int15. Void wait () throws interruptException Wait Throw InterruptException Exception 16. Java.lang.void is the wizard of the Void 17. Byte, Interger , Double ... All the number of copies related packaging classes are inherited in Number

Interface interface) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ 1. All methods of interface are public, abstract, and non-static 2. All variables of the interface are public, static, final. Therefore, the variable of the interface cannot be changed, in its implementation class .3. Implementation of the interface to the interface must throw the same exception, not the child, this is not the same as Override! Similar If the interface method does not throw, the implementation method can not be thrown. 4. Implementing the implementation method must explicitly declare into public, not writing, ah !!! 5. Interface can not be declared into final, don't it How to be implemented (this seems to be nonsense. 6. A class implements two interfaces, if the two interfaces have the same way, implement the class, implement this method, no problem. Inner class of embedded INNER CLASS ~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ 1. Embedded category can access any variables of the Outer class, including private .2. Static Inner class, only any STIC variable of the Outer class 2.1 Inclusion category can be Final, Abstract 3. I rely on embedded categories within the method, can not be static: void test () {static class a {}} xxxxx !!!! 4. I rely on the embedded category within the method. Modifier, Void Test () {public class a {}} xxxxx !!!! 5. I rely on the inline category within the method, can only access the Final variable in the method, however, any variable of the Outer class can be accessed. 6. The anonymous class cannot have a constructor, but the parameters are declared, which is equivalent to the parameters 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 () {};} file: // classbcd extends ABCD {} compile error, because I know, New III () {}; actually anonymous class implementation III interface; new ABC () {}; actually anonymous class inherited ABC.8.? Class A {private a () {system.out.println ("a!");}} Class B Extends a {} I rely on, it is right! B instance, I will actively call the texture of the parent class A, even if It is private, it seems that there is 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, and the inside and outside, in the lock problem. 10. External class cannot Through this is accessed, this should refer to the internal class at this time, and the members who enjoy the external class are directly used. Don't add any qualitative words 11. How to use this? Please see: Class Outer {INT I; Class Inner {Class Innerinner {void Test () {}}}} See you, class name .this. Variable name, you can quote i, first see it, 嘿嘿, 寡 寡 .12. pay attention to this Two kinds of ways can be Class Outer.inner i = new outer (). New Inner (); or, class o = new outer (); class outer.inner i = = nnew inner (); thread) ~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ????? Go to Thread's API !!!!!! 1. Thread startup must pass through the start function. 2.Run function can only be public. 3. Threads have priorities from 1 to 10, through Thread.SetPriority (int);

Change, can not exceed 10, otherwise the operation is exception 4. Thread priority is 5, namely norm_priority.????????norm_priority is the static variable of Thread? 5. ???? thread.yeild ( Is a static method, so use the format is thread.yield (); she is forcing the current process to give up Cup.6.Sleep (1000), is a thread sleeping 1 second, then enter the READY state, pay attention, not the operation status that we have to wait to get the OS to schedule CUP.java.lang *;. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Cologne: int {} [] = {1 , 2}, null}; INT IB [] [] = (int [] []) ia.clone (); 2. What is Nan ????? Then look at CEIL (NAN), FLOOR (NAN) ,. ..3.math.floor (-1.1f); // - 2.0 math.ceil (-1.1f); // - 1.0 math.Round (-1.6d) // - 24.0 =

Is a variable name that does not meet the naming rules ???? Compile will be wrong .4. CHAR A = '/ u0001'; pair! Char b = / u0001; compile "! 5. Boolean B1, B2, B3, B4, B5; B1 = B2 == B3; B1 = B2 <= B3 && b4 == b5; b1 = b2 == b3 == True is all right! Both! Abnormal! B1 = B2 == B3 == B4 XXXXXXXXX compilation! 6. 1 >> 1 is 07.% = << = = >> = >>> is a legal symbol 8. --1-10 * 4 This way is correct, that is, (--1) -10 * 49 K = 1; K K ; result is 7, equivalent to ( 2) (2 ) ( 3) 10. The label cannot indicate. Hi: if: ife {breaf hi; File: // Break Hi1; No, you can't turn back} file: // hi1: No, you can't put it before INT i; hi1: i = 1; 11.public static void main (string s []) THROWS EXCEPTION {} Can be throwing out of the exception 12. Hi: if (b == true) {Break Hi;} Break label, can be used inside if, other, including Break, Continue label .13.It. X = i * -j; I rely, no problem !!! Compilation is true! int x = i * j i ; this is no problem, variable modifier (modifier) ​​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~ 1. The outermost class cannot be declared into protect and pravite 2. Two instances of the same class can access each other's private methods and private variables, cool 3.protect and no modifications The specific difference between the characters ??????? About outsourcing can access the sub-class access to which is? 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 expect 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) (" Hi , PARENT ")};} Class Child Extends Parent {Static Void Test () {System.out.pri NTLN ("hi, child")};} Parent P = new child (); p.Test (); file: // Say is Hi, Parent! 7. Static method can call .new Child () .test (); and child.test (); all OK! 8.Transient can only be used on a member variable in the class, cannot be used in the method .9.Transient variable cannot be Final and Static 10.native method Can be private, abstractd process control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unacceptable statement declaration is wrong: while (false) {}; for (; false {}; if (false) {} can not be compiled 2.FOR (first part; the first part can be used to declare or assign the value, but not Both are 3.

BYTE B; Switch {Case 200: // 200 Not in Range of Byte, because 200 exceeds B range, compiling errors 4. The label is reached to the label position, from the newly entered the loop 5 behind the label. Break with label interrupts the current loop and transferred the end transformation and trace of the loop of the label mark (converting and casting) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ binary Operators Convert the Smaller (Less) PRECISE) OPERAND to TYPE OF THE LARGER (More Precise) Operand. All Operators Will Convert Things Smaller Than INTS To INTS OR LARGER. This Includes Char 'S! 1.Byte, Char, Short defaults to int2.Byte-> short -> int-> long-> float-> Doublechar ^ This is the default direction to transform, but it is necessary to explicit Cast! Special attention: long-> float is the default, don't look at long64, float32, 嘿嘿 is It can be seen, can't change between 3.float f = 1/3; ok! Float f = 1.0 / 3.0; compilation error, because 1.0 / 3.0 result is Double, 噢 ~, wrong !! 4.int i = 1; Byte B = i; wrong! Need to explicit Cast.Final i = 1; byte b = i; just ok! I don't know why, final is ok. And according to my experiment Only INT and BYTE are related, others can't .5.Int i []; object [] obj = i; wrong! Object obj = i; 对! Array can only turn into Object, not Object [] 6.int i []; object [] obj; i = (int []) OBJ; 对! Object can be translated into an array .i / o ~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. File class Some important methods: isFile (); isdirectory (); string [] list (); exists (); getabsolutePath (); getParent (); 2. By delete (); mkdir (); rename NewName); Manipulate files, but it can not change the content of the file 2.1 File class can not change the current directory without re-creating a File object .3.InputStreamReader (InputStream in, String encodingName); OutputStreamReader (OutputStream in, String encodingName); Encoding: 8859_1 is Latin -1, contains ASCII4. Close the CLOSE stream, automatically call flush.5.system.in, system.out, system.err, automatically created 6.randomaccessfile (File File, String Mode) by JVM; Mode, R RW

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

New Post(0)