1. What are the aspects of object-oriented features?
A: Object-oriented features are mainly in the following areas:
1) Abstraction: Abstraction is the process of constructing classes by summarizing the common features of a class of objects, including both data abstraction and behavioral abstraction. Abstractions focus only on what properties and behaviors the object has, and do not care what the details of those behaviors are.
2) Inheritance: Inheritance is the process of creating a new class from an existing class to get inherited information. The class that provides the inheritance information is called the parent class (the superclass, the base class), and the class that gets the inherited information is called the subclass (derived class).
3) Encapsulation: Encapsulation is generally considered to be the process and data surrounded, access to data only through the defined interface. The essence of object-oriented is to portray the real world as a series of completely autonomous and closed objects. The method we write in the class is a encapsulation of the implementation details, and we write a class that encapsulates the data and data operations. It can be said that encapsulation is to hide everything can be hidden, only to the outside world to provide the simplest programming interface (you can think of the difference between ordinary washing machine and automatic washing machine, it is obvious that the automatic washing machine package is better and easier to operate).
4) Polymorphism: Polymorphism means that objects of different subtypes are allowed to respond differently to the same message. The simple thing is to invoke the same method with the same object reference but do something different. Polymorphism is divided into compile-time polymorphism and run-time polymorphism. Runtime polymorphism can be interpreted as: when a system accesses the services provided by System B, System B has several ways of providing services, but everything is transparent to a system. Method overloads (overload) implement compile-time polymorphism (also known as pre-binding), while the method override (override) implements runtime polymorphism (also known as post-bind).
2, Scope public,private,protected, and do not write when the difference?
A: The difference is as follows:
Scope current similar Bun class other
Public√√√√
Protected√√√x
Default√√xx
Private√xxx
Defaults are default when not written. The default is equivalent to exposing (public) to other classes in the same package, and for other classes that are not in the same package are equivalent to private (private). A protected (protected) subclass is equivalent to exposing a class that is not a parent-child relationship in the same package as private.
3. Is String the most basic data type?
Answer: No. There are only 8 basic data types in Java: Byte, short, int, long, float, double, char, Boolean, except for the base type (PrimitiveType) and enumeration type (enumeration type). All that is left is the reference type (reference type).
4. Float f=3.4, is it correct?
Answer: not correct. 3.4 is a double, assigning a double type (double) to a float (float) belonging to the lower transformation (down-casting, also known as narrowing) will result in a loss of precision, so you need to force the type to convert float f= (float) 3.4; or write FLOATF =3.4f;.
5, short S1 = 1; S1 = s1 + 1; Is it wrong? short S1 = 1; S1 + = 1; Is it wrong?
Answer: for short S1 = 1; S1 = s1 + 1; since 1 is an int type, the result of the s1+1 operation is also an int type, which requires a cast type to be assigned to the short type. and short S1 = 1; S1 + = 1; can be compiled correctly because s1+= 1, equivalent to S1 = (short) (S1 + 1), which has an implicit coercion type conversion.
6. Does Java have goto?
A: Goto is a reserved word in Java and is not used in the current version of Java. (in the appendix to the Java programming Language, written by James Gosling (the father of Java), is a list of Java keywords with goto and const, but these two are keywords that are not currently available, So some places call it a reserved word, but I personally don't agree with that, because programmers familiar with C know that the words used in the System class library are called reserved words.
7, what is the difference between int and integer?
A: Java is a nearly pure object-oriented programming language, but for programming convenience or to introduce basic data types that are not objects, but in order to be able to use these basic data types as Object operations, Java introduces a corresponding package type (wrapper class) for each basic data type. The encapsulation class of int is integer, and the automatic sealing/unpacking mechanism is introduced from JDK1.5, so that they can be converted to each other.
Java provides a wrapper class for each primitive type:
Original type: boolean,char,byte,short,int,long,float,double
Package Type: boolean,character,byte,short,integer,long,float,double
8, the difference between & and &&?
The:& operator is used in two ways: (1) bitwise and; (2) Logical AND. The && operator is short-circuiting and arithmetic. The difference between the logic and the short-circuit is very large, although both require that the Boolean value on both sides of the operator is true the value of the entire expression is true. && is called a short-circuit operation because if the value of the expression on the left side of && is false, the expression on the right will be shorted out directly and will not be evaluated. Most of the time we may need to use && instead of &, for example, to verify that the user's name is not NULL and is not an empty string when validating the login, it should be written as: Username! = null &&!username.equals ("") , the order of the two cannot be exchanged, not the & operator, because if the first condition is not true, the equals of the string cannot be compared, otherwise a nullpointerexception exception will be generated. Note: Logical OR operator (|) and short-circuit or operator (| | The difference is also true.
9. Explain the usage of the in-memory stack (stack), heap, and static storage.
A: Usually we define a variable of a basic data type, a reference to an object, and a field save for a function call that uses the in-memory stack space, while the object created by the new keyword and the constructor is placed in the heap space; the literal in the program (literal) is 100, "Hello" written directly And constants are placed in a static storage area. Stack space operation is the fastest but also very small, usually a large number of objects are placed in the heap space, the entire memory, including the hard disk of virtual memory can be used as heap space.
String str = new string ("Hello");
In the above statement, STR is placed on the stack, the string object created with new is placed on the heap, and the literal "hello" is placed in the static storage area.
A technique called escape analysis is used in the latest version of the JDK to put some local objects on the stack to improve the operational performance of the object.
10, Math.Round (11.5) equals how much? How much does Math.Round (-11.5) equal?
Answer: The return value of Math.Round (11.5) is the return value of 12,math.round (-11.5) is-11. Rounding is done by adding 0.5 to the parameter and then taking the next rounding.
11, whether the Swtich can function on a byte, whether it can function on a long, whether it can function on a string?
A: In the early JDK, in switch (expr), expr can be byte, short, char, Int. Starting with version 1.5, the enumeration type (enum) is introduced in Java, and expr can be an enumeration, starting with version 1.7, or string. A long integer is not possible.
12. Calculate 2 times 8 with the most efficient method?
A: 2 << 3 (shift left 3 is equivalent to 2 times the 3).
13. Does the array have the length () method? Does the String have the length () method?
Answer: The array does not have the length () method and has the length property. String has the length () method.
14. How do I jump out of the current multiple nested loops in Java?
A: Before the outermost loop, add a tag such as a, and then use break A; You can jump out of multiple loops. (Support for tagged break and continue statements in Java is somewhat similar to goto statements in C and C + +, but you should avoid using labeled break and continue as you want to avoid using goto)
15. Can the constructor (constructor) be rewritten (override)?
A: The constructor cannot be inherited and therefore cannot be overridden, but can be overloaded.
16, two object values are the same (x.equals (y) = = true), but can have different hash code, this sentence right?
A: No, if two objects x and y satisfy x.equals (y) = = True, their hash code (hash code) should be the same. Java for the Eqauls method and Hashcode method is this: (1) If two objects are the same (the Equals method returns True), then their hashcode values must be the same, (2) If two objects have the same hashcode, they are not necessarily the same. Of course, you may not have to do as required, but if you violate the above principles you will find that when using containers, the same objects can appear in the set set, while the efficiency of adding new elements is greatly reduced (for systems using hash storage, if the hash code conflicts frequently, the access performance will be drastically reduced).
17. Can I inherit the String class?
A: The String class is the final class and cannot be inherited. Inheriting the string itself is a bad behavior, and the best way to reuse string types is by associating rather than inheriting.
18, when an object is passed as a parameter to a method, this method can change the properties of the object, and can return the changed results, then this is the value of the pass or reference pass?
A: The value is passed. The Java programming language has only value-passing parameters. When an object instance is passed as a parameter to a method, the value of the parameter is a reference to the object. The contents of the object can be changed in the called method, but the object's reference is never changed. In C + + and C #, you can change the value of an incoming parameter by passing a reference.
19, the difference between String and StringBuilder, StringBuffer?
A: The Java platform provides two types of strings: string and Stringbuffer/stringbuilder, which can store and manipulate strings. Where string is a read-only string, meaning string content referenced by string cannot be changed. The string objects represented by the StringBuffer and StringBuilder classes can be modified directly. StringBuilder is introduced in JDK 1.5, and it is exactly the same as the StringBuffer method, except that it is used in a single-threaded environment because all aspects of it are not synchronized decorated. Therefore, it is also more efficient than stringbuffer.
20. The difference between overloading (overload) and overriding (override). Can overloaded methods be differentiated according to the return type?
A: The overloads and overrides of a method are implemented in a polymorphic way, except that the former implements the polymorphism at compile time, while the latter implements the runtime polymorphism. Overloads occur in a class, and methods with the same name are considered overloaded if they have different parameter lists (different parameter types, different number of arguments, or both); Overrides occur between subclasses and parent classes, and overrides require subclasses to be overridden by methods that have the same return type as the parent class, which is better accessed than the overridden method of the parent class. You cannot declare more exceptions than the parent class is overridden by the method (the Richter substitution principle). Overloads do not have special requirements for return types.
21. Describe the principle mechanism of the JVM loading class file?
A: The loading of classes in the JVM is implemented by the class loader (ClassLoader) and its subclasses, and the ClassLoader in Java is an important Java Runtime system component that is responsible for locating and loading classes in class files at run time.
Add:
1. Because of the cross-platform nature of Java, the compiled Java source program is not an executable program, but one or more class files. When a Java program needs to use a class, the JVM ensures that the class has been loaded, connected (validated, prepared, parsed), and initialized. Class loading refers to reading the data in the class's. class file into memory, usually by creating a byte array to read into the. class file, and then produce a class object corresponding to the loaded class. When the load is complete, the class object is not yet complete, so the classes are not available at this time. When a class is loaded, it enters the connection phase, which includes three steps for validating, preparing (allocating memory for static variables and setting default initial values), and parsing (replacing symbolic references with direct references). Finally, the JVM initializes the class, including: 1 If the class has a direct parent class and the class is not initialized, the parent class is initialized first, and 2 if there is an initialization statement in the class, the initialization statements are executed sequentially.
2. Class loading is done by the ClassLoader, which includes: Root loader (BootStrap), extension loader (Extension), System loader (systems), and user-defined class loaders (subclass Java.lang.ClassLoader). Starting with JDK 1.2, the class loading process took the Father delegation mechanism (PDM). PDM better guarantees the security of the Java platform, in which the JVM's own bootstrap is the root loader, and the other loaders have only one parent class loader. The load of a class first requests that the parent ClassLoader be loaded, and the parent ClassLoader is not loaded by its child ClassLoader. The JVM does not provide a reference to the bootstrap to the Java program. The following is a description of several class loaders:
A) Bootstrap: generally implemented with native code, responsible for loading the JVM base Core class library (Rt.jar);
b) Extension: Loads the class library from the directory specified by the Java.ext.dirs system property, and its parent loader is bootstrap;
c) System: Also called the application ClassLoader, whose parent class is extension. It is the most widely used class loader. It is the default parent loader for the user-defined loader, which records the class from the environment variable classpath or the directory specified by the system attribute Java.class.path.
22. Can I store a Chinese character in char type?
A: The char type can store a Chinese character because the encoding used in Java is Unicode (no specific encoding is selected, the character is used directly in the character set, this is the only way to unify), and a char type is 2 bytes (16bit), so putting a Chinese is no problem.
Supplement: Using Unicode means that characters have different representations both inside and outside the JVM, Unicode within the JVM, and encoded when the character is transferred from inside the JVM to the outside (for example, to a file system). So in Java there are byte stream and character stream, as well as conversion stream between character stream and byte stream, such as InputStreamReader and Outputstreamreader, these two classes are the adapter classes between byte stream and character stream, which assume the task of encoding conversion.
23. What are the similarities and differences between abstract class and interface (interface)?
A: Abstract classes and interfaces cannot be instantiated, but you can define references to abstract classes and interface types. If a class inherits an abstract class or implements an interface that requires all of its abstract methods to be implemented, the class still needs to be declared as an abstract class. Interfaces are more abstract than abstract classes, because constructors can be defined in abstract classes, can have abstract methods and concrete methods, and constructors are not defined in an interface, and the methods are all abstract methods. Members in an abstract class can be private, default, protected, public, and members of the interface are all public. Member variables can be defined in an abstract class, whereas member variables defined in an interface are actually constants. Classes with abstract methods must be declared as abstract classes, and abstract classes may not necessarily have abstract methods.
24. What is the difference between static nested classes (the static Nested Class) and inner classes (Inner Class)?
A: The static Nested class is an inner class that is declared static (static), and it can be instantiated without relying on an external class instance. The usual inner classes need to be instantiated after the external class is instanced.
25. There is a memory leak in Java, please describe it briefly.
A: In theory, Java has no memory leaks due to garbage collection (GC) (which is an important reason why Java is widely used in server-side programming); However, in actual development, there may be useless but accessible objects that cannot be reclaimed by GC and memory leaks occur. One example is that the objects in Hibernate's session (cache) are persistent, and the garbage collector does not reclaim those objects, but there may be garbage objects that are useless.
26. Whether the abstract method can be static at the same time (static), whether it can be a local method (native), and whether it can be synchronized modified at the same time?
Answer: No. Abstract methods require subclasses to rewrite, and static methods cannot be overridden, so they are contradictory. Local methods are methods implemented by local code, such as C code, and abstract methods are not implemented and are contradictory. Synchronized is related to the implementation details of the method, and the abstract method does not involve implementation details, and therefore is contradictory to each other.
27. What is the difference between a static variable and an instance variable?
A: A static variable is also called a class variable, belongs to a class, does not belong to any object of the class, no matter how many objects are created, a static variable is in memory and has only one copy; the instance variable must be dependent on an instance, and the object needs to be created before it can be accessed through the object.
28. Is it possible to make a call to a non-static (Non-static) method from within a static method?
A: No, static methods can only access static members, because a call to a non-static method creates an object first, and then when the static method is called, the object may not be initialized.
29, how to implement object cloning?
Answer: There are two ways:
1. Implement the Cloneable interface and rewrite the Clone () method in the object class;
2. Implement the serializable interface to achieve cloning through serialization and deserialization of objects.
30. What is GC? Why do you have a GC?
A: GC is the meaning of garbage collection, memory processing is the programmer is prone to problems, forget or wrong memory recycling will cause the program or system instability or even crash, Java provides the GC function can automatically monitor whether the object exceeds the scope to achieve the purpose of automatic recovery of memory, The Java language does not provide a display action method that frees allocated memory. Java programmers don't have to worry about memory management because the garbage collector is automatically managed. To request garbage collection, you can call one of the following methods: System.GC () or Runtime.getruntime (). GC ().
Garbage collection can effectively prevent memory leaks and effectively use memory that can be used. The garbage collector is typically run as a separate, low-priority thread, and in unpredictable cases the dead or unused objects in the heap are purged and reclaimed, and the programmer is not able to call the garbage collector in real time for garbage collection of an object or all objects. The recycling mechanism has the methods of generational replication garbage collection, token garbage collection, incremental garbage collection, and so on.
Add: Standard Java processes are both stack and heap. The stack holds the original local variables, and the heap holds the objects to be created. The basic Java platform algorithm for heap memory recycling and reuse is known as tagging and purging, but Java has improved it with "generational garbage collection." This method divides the heap memory into different areas with the Java object's life cycle, and may move objects to different areas during garbage collection:
2 Eden: This is the area where the object was originally born, and for most objects, this is the only area where they exist.
2 survivor's Paradise (Survivor): The objects that survived from Eden will be moved here.
2 Lifelong Home Garden (tenured): This is the end of an old enough survivor. The Young Generation Collection (MINOR-GC) process is not going to touch this place. When the young generation collects objects that cannot be placed into a lifelong home garden, it triggers a full collection (MAJOR-GC), which may also involve compression in order to make enough space for large objects.
JVM parameters related to garbage collection:
2-XMS/-XMX---The initial size of the heap/maximum size of the heap
2-XMN---The size of the young generation in the heap
2-XX:-DISABLEEXPLICITGC---let System.GC () not have any effect
2-xx:+printgcdetail---print GC details
-xx:+printgcdatestamps---Print the timestamp of the GC operation
31. String S=new string ("xyz"), how many string objects have been created?
A: Two objects, one is the "XyX" of the static store, and the other is the object created on the heap with new.
32. Is the interface inheritable (extends) interface? is an abstract class achievable (implements) interface? Can abstract classes inherit concrete classes (concrete Class)?
A: An interface can inherit an interface. Abstract classes can implement (implements) interfaces, and abstract classes can inherit entity classes, but only if the entity classes must have explicit constructors.
33. Can a ". Java" source file contain more than one class (not an inner class)? What are the restrictions?
A: Yes, but there can be at most one public class in a source file and the file name must be fully consistent with the class name of the public class.
34, Anonymous Inner Class (anonymous inner Class) can inherit other classes? Is it possible to implement an interface?
A: You can inherit other classes or implement other interfaces, which are common in swing programming.
35. Can the inner class refer to the members of his containing class? Are there any restrictions?
A: An inner class object can access the members of the external class object that created it, including private members.
36. What are the uses of the final keyword in Java?
A: Indicates that the class cannot be inherited, and is a top-level class.
37, the following procedures to indicate the results of the operation:
Class a{
static{
System.out.print ("1");
}
Public A () {
System.out.print ("2");
}
}
Class B extends a{
static{
System.out.print ("a");
}
Public B () {
System.out.print ("B");
}
}
public class hello{
public static void Main (string[] ARS) {
A ab = new B ();
AB = new B ();
}
}
A: Execution result: 1a2b2b. When you create an object, the constructor is called in the order that it initializes the static member, then calls the parent class constructor, initializes the non-static member, and finally calls itself the constructor.
38. Conversion between data types:
1) How do I convert a string to a base data type?
2) How do I convert a base data type to a string?
For:
1) Call the method Parsexxx (string) or valueof (string) in the wrapper class corresponding to the base data type to return the corresponding base type;
2) One way to do this is to connect (+) The base data type with an empty string ("") to get its corresponding string, and another method is to call valueof (...) in the string class. method returns the corresponding string
39, how to implement the reversal and substitution of strings?
A: There are many ways to write your own implementation or you can use the methods in string or Stringbuffer/stringbuilder.
40. How do I convert a GB2312 encoded string to a iso-8859-1 encoded string?
A: The code looks like this:
String S1 = "Hello";
String s2 = newstring (S1.getbytes ("GB2312"), "iso-8859-1");
41. Date and Time:
1) How to get the month, day, hour minute seconds?
2) How do I get the number of milliseconds from January 1, 1970 0:0 0 seconds to now?
3) How to get the last day of a month?
4) How do I format a date?
A: The action method is as follows:
1) Create a Java.util.Calendar instance, call its get () method to pass in a different parameter to get the value corresponding to the parameter
2) The following methods are available for this number of milliseconds:
Calendar.getinstance (). Gettimeinmillis ();
System.currenttimemillis ();
3) The sample code is as follows:
Calendartime = Calendar.getinstance ();
Time.getactualmaximum (Calendar.day_of_month);
4) The date can be formatted by using the format (date) method in a subclass of Java.text.DataFormat such as the SimpleDateFormat class.
42, print the current moment yesterday.
For:
public class Yesterdaycurrent {
public static void Main (string[] args) {
Calendar cal = Calendar.getinstance ();
Cal.add (Calendar.date,-1);
System.out.println (Cal.gettime ());
}
}
43, compare Java and javasciprt.
A: JavaScript and Java are the two different products developed by the two companies. Java is the object-oriented programming language of the original Sun company, especially suitable for Internet application development, and JavaScript is the original Netscape company's products, In order to extend the functionality of the Netscape browser, a kind of object-based and event-driven interpretive language that can be embedded in the Web page, formerly known as LiveScript, was developed, whereas Java was formerly the Oak language.
The following comparisons are made between the two languages:
1) Object-based and object-oriented: Java is a true object-oriented language, and even if you are developing a simple program, you must design the object; JavaScript is a scripting language that can be used to create complex software that is independent of the network and interacts with the user. It is an object-based (object-based) and event-driven (Event-driven) programming language. Thus it itself provides a very rich internal object for designers to use;
2) Interpretation and compilation: Java's source code must be compiled before it is executed; JavaScript is an explanatory programming language whose source codes do not need to be compiled and interpreted by the browser;
3) Strongly typed variables and type weak variables: Java uses a strongly typed variable check, that is, all variables must be declared before compiling, and the variable declaration in JavaScript with its weak type. That is, the variable does not need to be declared before it is used, but rather the interpreter checks its data type at run time;
4) Code format is not the same.
Add: The most important difference between Java and JavaScript is that one is a static language and one is a dynamic language. The development trend of current programming language is functional language and dynamic language. In Java, classes are a class-one citizen, while JavaScript functions are a one-off citizen.
44. When to use assert?
A: Assertion (assertion) is a common debugging method in software development, which is supported in many development languages. In general, assertion is used to ensure the most basic and critical correctness of the program. Assertion inspection is usually turned on during development and testing. To improve performance, the assertion check is usually turned off after the software is released. In the implementation, the assertion is a statement that contains a Boolean expression that is assumed to be true when the statement is executed, and a assertionerror is reported if the expression evaluates to False.
Assertions are used for debugging purposes:
ASSERT (a > 0); Throws an Assertionerror IFA <= 0
Assertions can be of two forms:
Assert Expression1;
Assert Expression1:expression2;
Expression1 should always produce a Boolean value.
Expression2 can be any expression that yields a value, which is used to generate a string message that displays more debugging information.
Assertions are disabled by default, and you need to use the source 1.4 tag to enable assertions at compile time:
Javac-source 1.4 Test.java
To enable assertions at run time, you can use-enableassertions or-ea tags.
To choose to disable assertions at run time, you can use-da or-disableassertions tags.
To enable assertions in a system class, you can use the-esa or-DSA tags. You can also enable or disable assertions on a package basis. You can place assertions at any location that you expect to not arrive normally. Assertions can be used to validate parameters passed to a private method. However, assertions should not be used to validate parameters passed to public methods, because the public method must check its parameters regardless of whether the assertion is enabled or not. However, assertions can be used in public methods or in non-public methods to test the post conditions. In addition, the assertion should not change the state of the program in any way.
45. What is the difference between Error and exception?
A: Error indicates system-level errors and exceptions that the program does not have to handle, a serious problem in situations where recovery is not impossible but difficult, such as memory overflow, which cannot be expected to be handled by the program, and Exception represents an exception that needs to be captured or handled by the program. is a design or implementation problem; That is, it indicates that it will never happen if the program is running normally.
46, try{} has a return statement, then immediately after this try finally{} code will not be executed, when executed, before or after return?
A: It executes and executes before return.
47, the Java language how to do exception handling, keywords: throws, throw, try, catch, finally how to use each?
A: Java uses an object-oriented approach to exception handling, classifying various exceptions and providing a good interface. In Java, each exception is an object, which is an instance of the Throwable class or its subclasses. When an exception is thrown, a method throws an exception object that contains the exception information, and the method that invokes the object can catch the exception and handle it. Java exception handling is achieved through 5 keywords: try, catch, throw, throws, and finally. In general, a try to execute a program, if an exception occurs, the system throws (throw) an exception, when you can catch it by its type (catch) it, or finally (finally) by the default processor, try to specify a block to prevent all "exceptions" program The catch clause immediately follows the TRY block to specify the type of "exception" you want to catch, and the throw statement is used to explicitly throw an "exception"; throws is used to indicate the various "exceptions" that a member function might throw; finally to make sure that a piece of code doesn't matter what "exception" is occurring are executed in a piece of code; You can write a try statement outside of a member function call and write another try statement inside the member function to protect the other code. Whenever a try statement is encountered, the "exception" frame is placed above the stack until all the try statements are completed. If the next-level try statement does not handle an "exception", the stack expands until it encounters a try statement that handles this "exception."
48. What are the similarities and differences between run-time anomalies and inspected anomalies?
A: An exception indicates an unhealthy state that may occur during a program's operation, a run-time exception that represents an exception that may be encountered during a typical operation of a virtual machine, and is a common running error that usually does not occur if no problem is programmed. The exception that is checked is related to the context in which the program is running, even if it is programmed correctly, and can still be caused by a problem. The Java compiler requires that the method must declare the exception that is expected to be thrown, but does not require that an uncaught run-time exception be declared.
49. List some of your common run-time exceptions?
For:
ArithmeticException
ClassCastException
IllegalArgumentException
Indexoutofboundsexception
NullPointerException
SecurityException
50, final, finally, finalize the difference?
A: The final: modifier (keyword) has three uses: If a class is declared final, it means that it can no longer derive a new subclass, i.e. it cannot be inherited, so it and abstract are antonyms. Declaring variables as final ensures that they are not changed in use, and that the variable declared as final must be given the initial value at the time of declaration, whereas in subsequent references only the non-modifiable can be read. A method that is declared final can also be used only and cannot be overridden in a subclass. Finally: usually put in the back of the Try...catch code block, which means that the program regardless of normal execution or exception, the code as long as the JVM does not shut down can be executed, you can release the external resources to write code in the finally block. The method defined in the Finalize:object class allows the use of the Finalize () method in Java to do the necessary cleanup before the garbage collector clears the object from memory. This method is called by the garbage collector when the object is destroyed, and by overriding the Finalize () method, you can defragment the system resources or perform other cleanup work.
---reproduced other sites for collection and study, if there is infringement of copyright or privacy, please private chat to delete
The path of Java learning--a simple basic question of face