Scjp key point record

Source: Internet
Author: User
Tags modifiers

Section 1: Declaration and Access Control
1. The number of elements cannot be specified in the declaration statement of the array.
2. The index subscript of the array is int type, short type, byte type, and char type can be converted to int type Automatically. Long TYPE leads to compilation errors.
3. Java does not support multi-dimensional arrays, but supports arrays.
4. You cannot have more strict access permissions for the rewrite method.
5. Pay attention to modifiers such as native, transient, synchronized, and volitile.
6. In the constructor, this (argument) can be used to call other overload constructor in this class.
7, super (this), this (argument) should be placed in the first sentence of the constructor
8. Order of object creation:
1: static variable initialization;
2: perform static initialization. If Multiple Static initialization blocks exist, they are executed in the written order;
3: Execute the constructor header, regardless of the explicit implicit this () or super () called;
4: Execute Explicit initialization of instance variables and instantiate initialization blocks;
5: Execute the code in the remaining Constructor
Bytes ---------------------------------------------------------------------------------------------------------------------
Section 2: Flow Control assertions, and Exception Handling
1, switch (a) {Case B :....} A can be byte, short, Char, INT (can be automatically converted to int); B is a constant expression, and the value must be known during compilation.
2. the compiler checks the value of byte B Based on A's data type, case 200 // compiler error because 200 out of range of byte
3. In the try/catch code block, when declaring the parameter type of the catch code block, declare the subclass and then declare the parent class.
4. the overwritten method cannot throw an exception that is not detected in the parent class.
Bytes ---------------------------------------------------------------------------------------------------------------------
Section 3: Language fundamentals
1. at most one file is declared as public, and the class name is the same as the file name.
2. The public class is not necessarily included in the file. When there is no public class, the file name should be different from the class name.
3. All methods in the interface are implicitly public and abstract modifiers (not static and other modifiers), and all variables are implicitly static, public, final rhetoric (not transient or volatile)
Bytes ---------------------------------------------------------------------------------------------------------------------
Section 6: overloading, overwriting, runtimetype, and object orientation
1. variable is resolved at compile time, method is resolved at run time, static method is resolved at compile time.
2. method calls depend on the object type rather than the referenced type. Therefore, it is impossible to call the parent class method of the parent class in the subclass, however, the reference type of this can be used to access the parent class variables of the parent class along the inheritance. Eg. (grandparent) (this). Variable
3. Method of private modifier is can't be extended. also can't be overwritted and overridden
Bytes ---------------------------------------------------------------------------------------------------------------------
About GC ()
The complete judgment rule for useless objects is: when the referenced contained relationship of an object does not trace the root object or the active thread, this object is called a useless object.
GC () is to "wake up" The garbage collection thread, which is equivalent to calling the notify () function for the garbage collection thread, but may not necessarily be executed. There are only two cases for the garbage collection thread:
JVM call: The system is idle and the memory resources are insufficient during running.
Java can be divided into code, Data, heap, and stack,
The memory area that garbage collection can only manage is limited to the heap area. Memory region allocation details: Java is similar to memory management in C/C ++.
An object is divided into two parts: the memory block to which the object is referenced and referenced. The reference declares in the function that the occupied space is opened in the stack zone where the function runs, depending on whether the function is running in the stack; the referenced memory block is handled by the garbage collection mechanism.
Invocation of polymorphism:
1. Compile
Determine whether the compilation is correct based on whether the Member is defined in the class of the object reference type. If the class corresponding to the reference type is defined as correct, or compile error. It can also be expanded to: If this member is not in the class corresponding to the reference type, and the member with the same name is defined in its parent class, the compilation is correct. If this member is not defined in the class corresponding to the reference type, compile error is defined in the subclass, that is, the parent class cannot reference the appended member in the subclass.
2. Run
When a member variable is called, the member variable in the class corresponding to the reference type is called. If this variable is not defined in this class, and the parent class defines the member variable with the same name, the variable with the same name in the parent class will be called. When calling a function, the member function will be called Based on the object's runtime type. When the runtime type is the type of the class, the member function defined in the class will be called. If the class is not defined, search for it in the parent class.
Constructor execution rules:
1. the constructor is always called up, And the constructor of the parent class is always executed before the constructor of the Child class can be executed.
2; In the constructor, if this (argument) statement is not used, there will be a super (argument) Statement (if hidden, System Auto insert super () to here ).
3. The explicit constructor always comes prior to the constructor statement.
Bytes ---------------------------------------------------------------------------------------------------------------------
Mouselistener, keylistener, windowlistener have event adapter.

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.