1 Final, finally, finalize the difference.
Final is used to declare properties, methods, and classes, respectively, that the property is immutable, that the method is not overridden, and that the class is not inheritable.
Internal classes to access local variables, local variables must be defined as final types, for example, a piece of code ...
Finally is part of the exception-handling statement structure, which indicates that it is always executed.
Finalize is a method of the object class that, when executed by the garbage collector, calls this method of the reclaimed object, and can override this method to provide garbage collection of other resource recycles, such as closing the file. The JVM does not guarantee that this method is always called
2 What are the similarities and differences between run-time exceptions and general exceptions?
An exception represents an unhealthy state that may occur during a program's run, and a run-time exception that represents an exception that may be encountered in a typical operation of a virtual machine is a common run error. The Java compiler requires the method to declare a non-runtime exception that might occur, but does not require that a runtime exception that is not caught to be thrown must be declared.
What is the difference between 3error and exception?
Error indicates a serious problem in situations where recovery is not impossible but difficult. For example, memory overflow. It is impossible to expect the program to handle such situations. Exception represents a design or implementation issue. That is, it means that if the program runs normally, it never happens.
The simple principle and application of exception handling mechanism in 4Java.
Exceptions are abnormal conditions or errors that occur when a Java program is run (not compiled), similar to real-life events, where real-life events can contain information about the time, place, people, and plot of an event, which can be represented by an object, and Java uses an object-oriented approach to handling exceptions. It encapsulates each exception that occurs in the program into an object that contains information about the exception.
Java classifies exceptions, different types of exceptions are represented by different Java classes, and the root class for all exceptions is java.lang.throwable,throwable two sub-classes are derived: Error and Exception,error Represents a serious problem that the application itself cannot overcome and recover, and the program has only a dead copy, such as a system problem such as memory overflow and thread deadlock. Exception said that the program can also overcome and restore the problem, which is divided into system anomalies and common anomalies, system anomalies are the defects of the software itself caused by problems, that is, the software developers to consider the problem caused by poor, software users can not overcome and restore this problem, In this case, however, the software system can continue to run or let the software die, for example, array scripting out of bounds (arrayindexoutofboundsexception), null pointer exception (NULLPOINTEREXCEPTION), Class Conversion Exception (classcastexception), common exception is the operation of the environment changes or anomalies caused by the problem, is the user can overcome the problem, for example, network disconnection, hard disk space is not enough, after such an exception, the program should not die.
Java provides a different solution for system exceptions and common exceptions, and the compiler enforces common exceptions that must try: Catch processing or using the throws declaration continues to be thrown to the upper call method processing, so the common exception is also called the checked exception, and the system exception can be handled or not handled, so the compiler does not enforce with try. catch processing or declaration with throws, so system exceptions are also known as unchecked exceptions.
According to three levels to think: the virtual machine must be down error, the program can die or can not die of errors, the program should not die error;
5 frequently seen runtime exception.
Java.lang.NullPointerException
Java.lang.ClassNotFoundException
SQLException
ClassCastException
Java.lang.ArrayIndexOutOfBoundsException
Analysis of exception suspects in Java