An incisive summary of Java Authentication

Source: Internet
Author: User
1. The switch can only contain short, Int, Char, and byte.

2. If (A = "A") Compilation error. If (A = false) compilation is OK because a = false represents a Boolean value.
3. Outer. Inner I = new outer (). New inner (); OK!
4. In the file, 8 is int by default, and 8.0 is double by default.
5. octal starts with 0, not O (English O)
6. byte-128 ~ 127,-128 is the binary number?
7.-1> 32 or-1,-1> 32. Why is it-1?
8. Char c = 'C'; string S = "S"; S + = C; the result is SC !!!
9. boolean b1 = true; Boolean b2 = true; system. Out. println (b1 | B2); the result is true. The compilation is correct!
10. What are the default import packages of Java?

AWT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. All components flowlayout will be compressed to their minimum size
2. This is what borderlayout's north, south, west, east, and center look like. The four words are case sensitive and must be written in this way. Otherwise, an error occurs?
2.1 If only add is used, and the value is left blank, the default value is medium.
2.2 If no component is added to the center, it will be empty.
2.3 if there is a component in a certain position, if you add component to it, it will overwrite the original
3. The default layout of the applet and panel is flowlayout.
4. frame. The default layout of dialog is borderlayout.
5. Inheritance relationships of various awe classes, frame, window, component ,...?
6. Window, frame, and dialog cannot be embedded in the container. Note: window!
7. The action event acts on the carriage return time of the button and textfeild.
8. The item event acts on the time when the selection of list, choice, and checkbox changes
9. If the container is invisible, the component before the new layout manager will follow the new layout change. If the container is visible, the component will not be affected by the subsequent layout.
10. The size of Components in gridlayout is the same.
11. In gridbaglayout, component can occupy multiple grids.
12. system. Exit (); calls are not allowed in the applet.

AWT event
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. event classes include
Semantic events: actionevent, adjustevent, itemevent, textevent
Low-level events: componentevent, containerevent, focusevent, inputevent, keyevent, mouseevent, paintevent, and windowevent
2. Listener:
Actionlistener, adjustlistener, compentlistener, containerlistener, focuslistener, itemlistener,
Keylistener, mouselistener, mousemotionlistener, textlistener, windwoslistener, 11 listener in total,
There are seven adpters, and four fewer are actionlisenter, adjustlistener, itemlistener, and textlistener. They only have one method.
3. mouselistener has five methods: clicked, pressed, released, entered, and exited.
4. There are two methods for mouse mousemotionlistener: mousedragged and mousemoved.

Class and Object)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
0. The outermost class can be declared as final: "$ file a": <final class A {}> OK !, But it cannot be private or static.
1. overload is the same method name in the same type, and override is the parent-child inheritance.
2. The returned results of override must be the same; otherwise, the compilation is incorrect.
The return type of an overriding method is identical to the return type of the method it overrides.
2.1 The modifier of override can be expanded, but cannot be reduced. for example, the sub-class of the parent class private void test () {}: Public void test () {}. No problem. If it is reversed, it will end up!
3. Super. Super (), by mistake. It's not written like this.
4. Never override between static and non-static!
5. Check the program
Public Class {
Void test1 () throws baseex {HI ();}
Void HI () {system. Out. println ("say hi, ");}
}
Class AA extends {
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 does this mean? Note: The method always follows the original face of the class. The variable is the opposite!
6. Do not override a non-abstract method into an abstract method.
7. The exception thrown by the override subclass method can only be a child exception class thrown by the parent class method, or no!
8. The constructor cannot be native, final, static, or synchronized. It can be public or private. Nothing is available.
9. You can write return in the constructor function, but nothing is allowed or even null (isn't that nonsense, haha)
10. The constructor cannot return values. We all know that, but if there is a "constructor" inverse value, don't worry, it's not a constructor, it's just a common function.
11. Super (); this (); these two functions can only be called in the constructor.
12. assign values when declaring member variables, which is earlier than the constructor. 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 An error occurred while throwing interruptexception.
16. java. Lang. Void is the void packaging class.
17. byte, interger, double... all number-Related Packaging classes are inherited from number

Interface)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. All methods of the interface are public, abstract, and non-static by default.
2. All variables of the interface are public, static, and final by default. Therefore, the variables of the interface cannot be changed in its implementation class.
3. The methods implemented by the interface implementation class must be the same as those thrown by the interface method, and are not allowed to be subclasses. This is different from override! Similarly, if the interface method is not flushed, the implementation method cannot be flushed.
4. the implementation method of the class must be explicitly declared as public, and nothing can be written, ah !!!
5. The interface cannot be declared as final, or how can it be implemented?
6. A class implements two interfaces. If the two interfaces have the same method, the implementation class implements this method. No problem.

Inner class)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. the embedded class can access any variables of the outer class, including private.
2. static inner class, which can only access any static variables of the outer class
2.1 The embedded class can be final or abstract
3. **, the embedded class in the method cannot be static: void test () {static Class A {}} XXXXX !!!!
4. **, the embedded classes in the method cannot contain any modifier, void test () {public class A {}} XXXXX !!!!
5. ** the embedded class in the method can only access final variables in the method, but can access any variables in the outer class.
6. The Anonymous class cannot have constructor, but parameters are included in the declaration, which is equivalent to passing 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 (){};}
// Class BCD extends ABCD {} compile error, because,
As you can see above, new III () {}; in fact, the anonymous class implements the III interface; new ABC () {}; in fact, the anonymous class inherits ABC.
8 .???
Class A {private A () {system. Out. println ("! ");}}
Class B extends {}
**, That's right! B will take the initiative to call the structure of the parent class A, even if it is private, it seems no problem !!!
9. The internal class can have the synchronized method, so the lock is the internal class, which has nothing to do with the external class. The internal and external classes are separated on the lock issue.
10. The external class cannot be accessed through this. This should refer to the internal class at this time. Members of the external class can be used directly without any restrictions.
11. how to use this? See:
Class outer {int I;
Class inner {
Class innerinner {
Void test (){
Outer. This. I = 1;
}
}
}
}
You can see it, class name. This. variable name, which can be referenced to I. For the first time, you can see it.
12. Note that both write methods can be used.
Class outer. Inner I = new outer (). New inner ();
Or, Class O = new outer (); Class outer. Inner I = O. New inner ();

Thread)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
????? Go to the thread Api !!!!
1. The thread must start through the start function.
2. The run function cannot or can only be public.
3. The thread has a priority from 1 to 10, which can be changed through thread. setpriority (INT);. The value cannot exceed 10. Otherwise, a running exception occurs.
4. The default thread priority is 5, that is, norm_priority .???????? Is norm_priority a static variable of thread?
5 .???? Thread. yeild (); is a static method, so the format is thread. Yield (); she forces the current process to discard the cup.
6. Sleep (1000) means that the thread sleeps for 1 second and then enters the ready state. Note that the thread is not in the running state and will wait for the OS to schedule it to get the cup.

Java. Lang .*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. cologne of the array: int Ia [] [] = {1, 2}, null}; int IB [] [] = (INT [] []) IA. clone ();
2. What is Nan ????? Then let's look at 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 are final and cannot be inherited.
6. Int round (float); long round (double); alas, round will never return a decimal point
7. Static double Ceil (double)
8. Static double floor (double) Note that Ceil and floor only have this double version, and everything is converted to double!
9. Static double sin (double radians); cos, Tan
10. New string ;? It can be byte []; char []; string; stringbuffer
11. Some functions of string: int length (); char charat (INT); string touppercase (); string tolowercase ();
12. String ("ABC"). Equals (string ("ABC") are not equal, otherwise there will be no Boolean equalsignorecase (string) Function
13. "012345678" is the sequential number of a string, indexof ('1'), indexof ("1") both return 1, substring (2345) is, hey: yes "[) "Feeling
14. Trim () even the tab is dequeed. "/T/N Java", trim () only has "Java" left.
15. For the object's cologne, go to the chatbot API ??????????????????????
16. "ABCD". Trim (), "ABCD" + new string ("Ef") are all reasonable statements.
17. Three constructors of stringbuffer: () the initial capacity is 16, (INT initial capacity), (string), and the initial capacity is the string length plus 16
18. stringbuffer functions: 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) {} compilation error! Because the S and SB types are different and cannot be compared.
Set:
1. Relationships between interfaces and classes. Only the last one is class.
Collection: List: vector, arraylist, sorted list
Map: sortedmap: treemap
Collection: Set: sortedset: treeset
Map: hashtable
Collection: Set: hashset
  
Base)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. The main of Java application can be non-public, but must be static.
2. A file can only have one public class, and it must be the same as the file name, including the case
3. The variable can only start with a letter, $, _, and the second variable can be a number.
4. ch/u0061r = 'a'; Char/u0063 = 'B'; char c = '/u0063'; are valid.
5.1e-5d, valid. The e-5d is invalid and must have the preceding Coefficient
6. Int [] I [] = {null {1, 2} is correct! Int I [] = {1, 2, 3,} Correct! "," The same effect as none
7. Local array, like variables, must be initialized before use
8. The main method can be final.

Operator and assignment)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. system. Out. printl (1 + 2 + "3"); // 33 system. Out. printl ("1" + 2 + 3); // 123
2. Int I = 0; I = I ++; Result, I = 0!
3. Int I []; Index = 0; I [Index] = Index = 5; the result is: I [0] = 5 ;!!!
4. byte B = 10; yes, because, 10 can be automatically converted from int to byte
5. Next, byte B = B + 10; no !! Because the int after 10 + B cannot be automatically converted from int to byte, I don't know why! Depend!
6. byte b1 = 4; byte b2 = 6; b1 = b1 + B2; error! Compilation error! After B1 + B2, it must be forcibly converted to byte, b1x1 + b2 );
7. The same XOR value is 0, not 1, 1, 1 = 0; 0, 0 = 0;/= 1
8. x = float. Nan compilation error, should be float. isnan
9. x = double. positive_infinity can be compiled.
10.-1 is 1111... 1111, <always right zero,> positive zero, negative one,> constant zero
10.1-1> the number of BITs is-1; 1 <31 is changed to a 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, B must be a class/interface, not an instance
  
-------- Supplement ------------------------------
1. byte, short, and char all have Var =-var; compilation errors, because-VaR has been automatically converted to an int type.
2. INT/0 will throw arithmeticexception
Double, float/0, inf or-INF
Nan, 0/0
3. Int a-B-c; is a variable name that does not comply with the naming rules ???? Compilation will fail.
4. Char A = '/u0001'; right! Char B =/u0001; Compilation error!
5. boolean B1, B2, B3, B4, B5;
B1 = b2 = B3;
B1 = b2 <= B3 & B4 = B5;
B1 = b2 = B3 = true
All are correct!
B1 = b2 = B3 = B4 xxxxxxx compilation error!
6. 1> 1 is 0
7.% = <<=>>>>>> are valid symbols
8. -- 1-10*4 is correct, that is, (-- 1)-10*4.
9. k = 1; ++ K + k ++ K; the result is 7, equivalent to (++ 2) + (2 ++) + (+ 3)
10. The label cannot be declared.
Hi:
If {
Break Hi;
// Break hi1; no, it cannot be reversed
}
// Hi1: No. It cannot be placed before the declaration.
Int I;
Hi1:
I = 1;
11. Public static void main (string s []) throws exception {} Yes, main can throw an exception
12. Hi:
If (B = true) {break Hi ;}
The break number, which can be used in If. Nothing else can be used, including the break and continue number.
13. Int x = I *-J; **. No problem !!! Compilation is correct! Int x = I * j ++ I ++,

Modifier)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. classes at the outermost layer cannot be declared as protect and pravite
2. Two instances of the same class can access each other's private methods and private variables.
3. What is the difference between protect and non-modifier ??????? Which of the following services can access quilt access through outsourcing?
4. After the member variable is modified to final, it must be declared with an initial value or an initial value assigned to the constructor. Don't expect her to get the default value.
5. the abstract method cannot be static !!!
6. The static method will change with the change of the class. See the example below:
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 (); // indicates hi, parent!
7. Static methods can be called through the instance of the class.
New Child (). Test (); and child. Test (); are OK!
8. Transient can only be used in member variables of the class, but not in methods.
9. The transient variable cannot be final or static.
10. The native method can be private or abstractd.

Process Control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. The statements that are not reachable are declared as error: While (false) {}; for (; false {}; if (false) {} cannot be compiled.
2. For (the first part of; can be used to declare or assign values, but not both.
3. byte B; Switch {Case 200: // 200 not in range of byte, because 200 is beyond the range of B, the compilation error is returned.
4. The labelled continue reaches the position of the tag, and enters the cycle next to the tag.
5. The labelled break will interrupt the current loop and move it to the end of the tag-marked loop.

Converting and casting)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Binary operators convert the smaller (less precise) operand to the type of the larger (more precise) operand.
All operators will convert things smaller than ints to ints or larger. This contains des Char's!
1. byte, Char, and short are converted to int by default.
2. byte-> short-> int-> long-> float-> double
Char ^
This is the default direction for transformation. In contrast, explicit cast is required! Note: Long-> float is the default value. Do not look at long64, float32,
Also, we can see that char, byte, and short cannot be converted to each other by default.
3. Float F = 1/3; OK! Float F = 1.0/3.0; Compilation error, because the result of 1.0/3.0 is double ~, Wrong !!
4. Int I = 1; byte B = I; error! Explicit cast is required.
Final I = 1; byte B = I; OK! I don't know why. Final is fine. In my experiment, only the relationship between int and byte is like this.
5. Int I []; object [] OBJ = I; error! Object OBJ = I; yes! An array can only be converted into an object, not an object []
6. Int I []; object [] OBJ; I = (INT []) OBJ; right! Objects can be converted to an array explicitly.

I/O
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Some important methods of the file class: isfile (); isdirectory (); string [] list (); exists (); getabsolutepath (); getparent ();
2. You can use Delete (); mkdir (); rename (File newname); to manipulate a file, but cannot change the file content.
2.1 The File class cannot change the current directory unless a file object is created again.
3. inputstreamreader (inputstream in, string encodingname );
Outputstreamreader (outputstream in, string encodingname );
Encoding: 8859_1 is Latin-1 and contains ASCII
4. If you close a stream, flush is automatically called.
5. system. In, system. Out, system. Err, automatically created by JVM
6. randomaccessfile (File file, string mode); mode, R, RW

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.