One of the scjp Certification Exam review notes Series

Source: Internet
Author: User

Hope that the knowledge points will be helpful to those who are preparing to pass the scjp exam! If there are errors, you are welcome to criticize and correct them.

  1. The thread class is defined in the Java. lang package. Sleep () and yield () are static methods of thread. However, wait (), Policy (), and policyall () are instance methods of the object class. To start a thread, you must call the START () method. However, the specific time when the thread starts to run is related to the operating system and virtual machines.
  2. Remember that the string class cannot be modified at any time, but do not think that calling some methods will certainly create a new object. When the Concat (), trim (), touppercase (), and tolowercase () Methods of the string instance are called, if the instance does not change after the call, no object will be created. Run the following program to get four true values.
    Public class teststring
    {
    Public static void main (string [] ARGs)
    {
    Teststring Ts = new teststring ();
    TS. Test ();
    }
     
    Public void test ()
    {
    String lower = "mingjava ";
    String upper = "mingjava ";

    System. Out. println (lower = lower. tolowercase ());
    System. Out. println (upper = upper. touppercase ());
    System. Out. println (lower = lower. Trim ());
    System. Out. println (lower = lower. Concat (""));
    }
    }
  3. All exceptions are inherited from throwable. Its two branches are error and exception. Both error and runtimeexcepton are called uncheckedexception. Other exceptions are called checkedexception. Error and runtimeexception do not need to be captured. We can't do anything about error, but the emergence of runtimeexception is your error. You should check your code. If the method does not use throws to declare checkedexception, a compilation error will also occur if you capture it!
  4. Remember that the subscript of the array starts counting from 0. Sometimes you will find this problem in main (string [] ARGs ).
  5. The internal class has unlimited access permissions to its enclosing class, and can even access its private type variables. However, if the internal class wants to access a local variable, the local variable must be final. For example
    Public class test
    {
    Public void dosome ()
    {
    Final Int J = 100;

    Class innerclass
    {

    Public void print ()
    {
    System. Out. println (j );
    }
    }
    }
     
    }
  6. When a method is overloaded, the return value and the thrown exception cannot be distinguished by the same name. The function is the type and number of method parameters.
  7. Note> it is a signed shift,> It is a shift with zero compensation on the right. See the following example.

    Public class myclass
    {
    Public static void main (string argv [])
    {
    Int I = 0x80000000;

    System. Out. println (I );
    System. Out. println ("after>" + (I> 1 ));
    System. Out. println ("after >>>" + (I >>> 1 ));
    }

    }

  8. Arrayindexoutofboundsexception, nullpointerexception, arithmeticexception, numberformatexception. classcastexception are common runtimeexception, not complie exception
  9. The Declaration S such as string S = "XXXX" can be reused, but new string ("XXX") must create a new object. Compare system. out. println ("string" = "string") and system. out. result of println (new string ("string") = new string ("string ")
  10. Be careful when encountering a ++ and ++.
  11. Short-circuit operator | and & must be clear. If the condition before the short-circuit operator is true, the subsequent statements will be discarded and not executed.
  12. Transient can only modify variables, and it cannot be used with final static
  13. If you inherit the thread, you can not implement the public void run () method, but you must implement this method to implement the runnable interface.
  14. If no modifier is added before the method, it is visible in the package. Protected indicates that the package is visible and the subclass is visible.
  15. String overwrites the equals method of the object. This method compares the content of the string instance, and = compares the address.
  16. Byte, double, float, integer, long, and short inherit from number, character, and Boolean inherit from object.
  17. You have time to take a look at the constructor exams for several packaging classes.
  18. This statement is correct: int [] [] array = new int [3] [];
  19. You should be clear about the structure of the switch statement, and switch () You can accept the int char Parameter
  20. If you overwrite the public Boolean equals (Object object) method, you should overwrite the public int hashcode () at the same time ()
  21. Instanceof can be used in both Class and Interface

 

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.