Java review Summary: Java Object-Oriented Programming-exception capture and handling, packet and access control permissions

Source: Internet
Author: User

Java review Summary: Java Object-Oriented Programming-exception capture and handling, packet and access control permissions

 

1. Exceptions are a type of command flow that causes program interruption. When exceptions occur, if they are not properly processed, the program will be interrupted.

2. for exceptions, try... Try... Catch... Finally, catch exceptions in the try statement, and handle exceptions in the catch statement. Finally serves as the unified exit for exceptions. This code segment must be executed no matter whether an exception occurs or not.

3. The maximum parent class of an exception is throwable, which is divided into two subclasses: exception and error. Exception indicates an exception processed by the program, and error indicates a JVM error, which is not handled by the program developer.

4. when an exception occurs, the JVM automatically promotes the instantiation object of an exception class and matches the exception type in the catch statement. You can also use the upward transformation relationship of the object to directly catch all exceptions through exception.

5. Throws is used in the method declaration, indicating that this method does not handle exceptions.

6. Throw indicates that an exception is thrown manually in the method.

7. When creating a custom exception class, you only need to inherit the exception class.

8. assertion is a new function provided after jdk1.4. it can be used to detect program execution results. However, assertion is not recommended in development.

9. Using packages in Java can implement the card sending mode for writing by multiple people. Avoid repeated class names.

10. Use the package keyword in Java to put a class into a package.

11. You can use the Import Statement in Java to import an existing package.

12. If a program imports a class of the same name without a package, you must explicitly write "package. Class Name" during use ".

13. There are four types of access control permissions in Java: private, default, protected, and public.

14. Use the jar command to compress a package into a jar file for your use.

Related Article

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.