Java interview problem

xiaoxiao2021-03-06  66

The front part is a problem, the back part is the answer to some netizens, you will refer to it:

*********************************************************** *******************

First, talk about the difference between Final, Finally, Finalize.

Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)?

Third, Static Nested Class and Inner Class are different, the more you say, the better (the interview question is very general).

The difference between fourth, & and &&.

Fifth, the difference between HashMap and HashTable.

Sixth, the difference between Collection and Collectes.

Seventh, when do you use Assert.

Eighth, what is GC? Why have GC?

Ninth, string s = new string ("xyz"); created a few String Object?

Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal?

Eleventh, short s1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong?

12. What is the difference between SLEEP () and WAIT ()?

Thirteenth, have Java goto?

Fourteenth, there is a length () method for arrays? String has a length () method?

Fifteenth, the difference between overload and override. Can OVERLOADED methods change the type of return value?

Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference?

Seventest, give me a Runtime Exception you most often.

Eighteenth, what is the difference between ERROR and EXCEPTION?

Near 10th, List, SET, MAP inherits from a Collection interface?

Ten, what is the difference between Abstract Class and Interface?

Second Eleventh, abstract can be static at the same time, whether it can be native at the same time, is it SYNCHRONIZED?

Typographic, whether the interface can inherit the interface? Does the abstract class implement (IMPLEMENTS) interface? Does the abstract class can inherit the physical class (Concrete Class)?

On the thirteenth, starting a thread is Run () or start ()?

24. Is the constructor CONSTRUCTOR can be Override?

The second fifteenth, can you inherit the String class?

Twentydays, after a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?

27. There is a Return statement in try {}, then the code in finally {} in this try will not be executed, when is executed, before returnome or after?

Chapter 28. Program: 2 Multiply 8 equal to?

The second nine, the two object values ​​are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?

Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery? 31st, SWTICH Whether it can act on Byte, whether it can act on long, can it work on String?

Article 32. Program: Write a Singleton.

********************* The first person's answer abcdhy (Cheng Xu) **************** ******************

It's simple, not too hard.

First, talk about the difference between Final, Finally, Finalize.

Too long .... Don't write it.

Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)?

can

Third, Static Nested Class and Inner Class are different, the more you say, the better (the interview question is very general).

Know 80%, say no, understand it is too difficult

The difference between fourth, & and &&.

Bit and logic

Fifth, the difference between HashMap and HashTable.

Synchronize

Sixth, the difference between Collection and Collectes.

Interface practical class

Seventh, when do you use Assert.

Eighth, what is GC? Why have GC?

Automatic memory recovery, reduce memory leaks, improve system stability

Ninth, string s = new string ("xyz"); created a few String Object?

2 s and "xyz"

Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal?

I don't know. Random

Eleventh, short s1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong?

Need a short, but find an int

12. What is the difference between SLEEP () and WAIT ()?

Sleep () sleep specified time Wait () sleep, you need other threads to wake up

Thirteenth, have Java goto?

No, but Break can be the function of implementing some goto

Fourteenth, there is a length () method for arrays? String has a length () method?

No, there is

Fifteenth, the difference between overload and override. Can OVERLOADED methods change the type of return value?

No, overloaded must change the parameters

Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference?

Depending on the specific subclass, such as HashSet, it is compared to HashCode.

== is the same memory address of the comparative instance, and equals () is generally the specific content of the comparative example

Seventest, give me a Runtime Exception you most often.

NullPointersRexception, IOException

Eighteenth, what is the difference between ERROR and EXCEPTION?

Error is unrecoverable and must be stopped. The Exception is expected to recover.

Near 10th, List, SET, MAP inherits from a Collection interface?

MAP is not

Ten, what is the difference between Abstract Class and Interface?

It is the difference between Class and Interface. If you can say that the second eleventh, what can be a STATIC at the same time, whether it can be native at the same time, can you be synchronized?

You can't

Typographic, whether the interface can inherit the interface? Does the abstract class implement (IMPLEMENTS) interface? Does the abstract class can inherit the physical class (Concrete Class)?

All can

On the thirteenth, starting a thread is Run () or start ()?

START ();

24. Is the constructor CONSTRUCTOR can be Override?

Cannot

The second fifteenth, can you inherit the String class?

Cannot

Twentydays, after a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?

Yes, but you can't enter the SYNCHRONIZED method of the object.

27. There is a Return statement in try {}, then the code in finally {} in this try will not be executed, when is executed, before returnome or after?

Yes, when an abnormality occurs. Before return

Chapter 28. Program: 2 Multiply 8 equal to?

2 << 3

The second nine, the two object values ​​are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?

Can do this, but does not conform to Java specifications

Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery?

Reference

Thirty-first, whether SWTICH can act on byte, whether it can act on long, can it work on String?

Long and string are not. Byte can

Article 32. Program: Write a Singleton.

Public class aaa {

Private aaa II = new aaa ();

PRIVATE AAA () {};

Public aaa get () {

Return II;

}

}

I spent a few more, and I have answered it. If I have learned enough, please give pointers.

*********************** The second person's answer dengyin2000 ****************** *******************

First, talk about the difference between Final, Finally, Finalize.

Final-modifier (keyword) If a class is declared as Final, it means that it is no longer a new subclass and cannot be inherited as a parent class. Therefore, a class cannot be declared as Abstract, and it is declared as final. Declaring variables or methods to Final, ensuring that they are not changed in use. Variables that are declared for final must give initial values ​​at the time of declaration, and only read in future references, cannot be modified. The method that is declared as final is also available, can not be overloaded

Finally- provides a Finally block when processed. If you throw an exception, then the matching catch clause will execute, and then the control will enter the Finally block (if any).

Finalize-method name. Java technology allows the use of the Finalize () method to make the object to clear the object from the memory before making the necessary cleanup work. This method is called by the garbage collector when it is determined that this object is not referenced. It is defined in the Object class, so all classes have inherited it. Subclasses override the Finalize () method to organize system resources or perform other cleanup work. The Finalize () method is called by this object before the garbage collector deletes the object. Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)?

The anonymous internal class is an internal class without a name. You cannot extends other classes, but an internal class can be implemented as an interface, and is implemented by another internal class.

Third, Static Nested Class and Inner Class are different, the more you say, the better (the interview question is very general).

NESTED CLASS (generally C statement), Inner Class (typically Java said). The maximum difference between Java internal classes and C nested classes is whether there is a reference to the outside. Specific visible http://www.frontfree.net/articles/services/view.asp?id=704&page=1

Note: Static Inner Class means 1 creation of an object of a Static internal class, does not require an external class object, 2 cannot access an external class object from an object of a Static internal class

The difference between fourth, & and &&.

& Is a bit operator. && is the Boolean logic operator.

Fifth, the difference between HashMap and HashTable.

Both of the MAP interface, implement the unique key to a specific value.

The HashMap class is not classified or sorted. It allows a NULL key and multiple NULL values.

Hashtable is similar to HashMap, but NULL keys and NULL values ​​are not allowed. It is also slower than HashMap because it is synchronized.

Sixth, the difference between Collection and Collectes.

Collections is a class under java.util that contains a variety of static methods related to the collection.

Collection is an interface under java.util, which is a parent interface of a variety of collections.

Seventh, when do you use Assert.

As an assertion, a statement containing Boolean expression, assuming that the expression is TRUE when this statement is executed. If the expression is calculated as false, then the system will report an AssertionError. It is used to debug purposes:

Assert (a> 0); // throws an assertionerror if a <= 0

There are two forms of assertions:

Assert Expression1;

Assert Expression1: Expression2;

Expression1 should always produce a Boolean value.

Expression2 can be any expression that draws a value. This value is used to generate a String message displaying more debugging information.

As default, it is disabled by default. To enable assertions while compiling, you need to use Source 1.4 tags:

Javac -Source 1.4 Test.java

To enable assertion at runtime, you can use the -enableassertions or the -ea tag.

To disable assertion at runtime, you can use the -DA or the -disableAssertions tag.

To enable assertion in the system class, you can use the -esa or -dsa tag. You can also enable or disable assertions on the basis of the package. An assertion can be placed at any position that is not reached in normal conditions. As an assertation can be used to verify the parameters passing to the private method. However, assertions should not be used to verify parameters passing to the public method, as there is no matter whether it is enabled, the public method must check its parameters. However, it can be used in public methods or in a non-public method to use asserts to test the post condition. In addition, the assertion should not change the status of the program in any way.

Eighth, what is GC? Why have a GC? (Foundation).

GC is a garbage collector. Java programmers don't have to worry about memory management because the garbage collector will automatically manage. To request garbage collection, you can call one of the following methods:

SYSTEM.GC ()

Runtime.getRuntime (). GC ()

Ninth, string s = new string ("xyz"); created a few String Object?

Two objects, one is "XYX", one is a reference object S pointing to "XYX".

Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal?

Math.Round (11.5) Returns (long) 12, Math.Round (-11.5) Returns (long) -11;

Eleventh, short s1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong?

Short S1 = 1; S1 = S1 1; error, S1 is the short type, S1 1 is INT type, cannot explicitly convert to a SHORT type. Can be modified to S1 = (Short) (S1 1). Short S1 = 1; S1 = 1 is correct.

Chapter 12, Sleep () and Wait () What is the difference? What is the favorite of thread?

The SLEEP () method is to stop the thread to stop a period of time. After the SLEEP time interval is full, the thread does not necessarily resume it immediately. This is because at that moment, other threads may be running and are not scheduled to give up execution unless (a) "wake up" thread has higher priority.

(b) The thread is running is blocked for other reasons.

Wait () is a thread interaction if the thread issues a wait () call, the thread is suspended, the object is adjusted to the waiting state until it is awake or waiting time.

Thirteenth, have Java goto?

The reserved word in Goto-Java is not used in Java.

Fourteenth, there is a length () method for arrays? String has a length () method?

The array does not have Length () method, with the properties of the length.

String has a length () method.

Fifteenth, the difference between overload and override. Can OVERLOADED methods change the type of return value?

The method of rewriting Overriding and overloading overloading is a different manifestation of Java polymorphism. Overriding Overriding is a manifestation of polymorphism between parent class and subclasses, and overloading overloading is a manifestation in a class. If a method is defined in the subclass with the same name and parameters as its parent class, we say that this method is overriddled. When the subject of subclass uses this method, the definition of the subclass will be called. For it, the definition in the parent class is like "shielded". If a plurality of the same names are defined in a class, they or have different parameters or different parameter types, called overloading. The way OVERLOADED is to change the type of return value. Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference?

The elements in the set cannot be repeated, then use the iterator () method to distinguish whether you are repeated. Equals () is the judgment of whether two SETs are equal.

Equals () and == Method Decide whether the reference value points to the same object Equals () override in the class, which is the true value of the content and type of two separate objects.

Seventest, give me a Runtime Exception you most often.

ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException,

ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException

Eighteenth, what is the difference between ERROR and EXCEPTION?

Error indicates a serious problem that recovery is not impossible but difficult. For example, memory is overflow. It is impossible to expect the program to handle this situation.

Exception represents a design or implementation problem. That is, it means that if the program runs normally, it will never occur.

Near 10th, List, SET, MAP inherits from a Collection interface?

List, SET is

MAP is not

Ten, what is the difference between Abstract Class and Interface?

The presence of a declaration method does not implement its class called abstract class, which is used to create a class that reflects certain basic behavior and declares the class, but cannot implement this class in this class. Case. An instance of the Abstract class cannot be created. However, you can create a variable, which is an abstract class and let it point to an instance of the specific subclass. There is no abstract constructor or abstract static method. Subclasses of the Abstract class provide implementation for all abstraction methods in their parent class, otherwise they are also abstract classes. Instead, this method is implemented in the subclass. Other classes that know their behavior can be implemented in the class. Interface is a variant of an abstract class. In the interface, all methods are abstract. Multiple inheritance can be obtained by achieving such an interface. All methods in the interface are abstract, no probabilities. The interface can only define the Static Final member variable. The implementation of the interface is similar to the subclass, except that the implementation class cannot inherit behavior from the interface definition. When the class implements a special interface, it defines the method of all such an interface (that is, the program body is given). Then, it can call the interface to call the interface on any object of the class of the interface. Because there is an abstract class, it allows the interface name as the type of reference variable. The usual dynamic cable will take effect. The reference can be converted to an interface type or a slave interface type, and the InstanceOf operator can be used to determine whether an object is implemented.

Second Eleventh, abstract can be static at the same time, whether it can be native at the same time, is it SYNCHRONIZED?

both are not

Typographic, whether the interface can inherit the interface? Does the abstract class implement (IMPLEMENTS) interface? Does the abstract class can inherit the physical class (Concrete Class)?

The interface can inherit the interface. Abstract classes can be implemented, whether abstract classes can inherit physical classes, but provided that the entity class must have a clear constructor.

On the thirteenth, starting a thread is Run () or start ()?

Starting a thread is to call the start () method so that the virtual process representing the thread is in operation, which means it can be scheduled and executed by the JVM. This doesn't mean that the thread will run immediately. The Run () method can generate a flag that must be exited to stop a thread.

24. Is the constructor CONSTRUCTOR can be Override?

The constructor constructor cannot be inherited, so Overriding cannot be overridden, but Overloading can be overloaded.

The second fifteenth, can you inherit the String class?

The String class is that the final class cannot be inherited.

Twentydays, after a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?

No, a Synchronized method of an object can only be accessed by one thread.

27. There is a Return statement in try {}, then the code in finally {} in this try will not be executed, when is executed, before returnome or after?

Will be executed, execute before return.

Chapter 28. Program: 2 Multiply 8 equal to?

Programmers with C background especially like to ask this question.

2 << 3

The second nine, the two object values ​​are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?

No, there is the same Hash Code.

Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery?

It is a value transfer. The Java programming language is only passed by the value. When an object instance is transmitted to the method as a parameter, the value of the parameter is a reference to the object. The content of the object can be changed in the called method, but the reference to the object will never change. Thirty-first, whether SWTICH can act on byte, whether it can act on long, can it work on String?

Switch (expr1), expr1 is an integer expression. Therefore, the parameters passing to the Switch and the CASE statement should be int, short, char or byte. Long, String can not work on SWTICH.

Article 32. Program: Write a Singleton.

The main role of the Singleton mode is to ensure that only one example exists in a Java application.

General Singleton mode usually has several forms:

The first form: Define a class, its constructor is private, it has a type of PRIVATE for a Static, an instantimeter of the class initialization, get a reference to it through a public GetInstance method, then call it Methods.

Public class singleton {

Private kindleton () {}

// Is it very strange to define an instance inside yourself?

// Note this is Private only for internal calls

Private static singleleton instance = new singleleton ();

/ / Here is a static method for accessing this Class, you can directly access

Public static singleleton getinstance () {

Return Instance;

}

}

The second form:

Public class singleton {

Private static singleton instance = null;

Public static synchronized singleton getInstance () {

// This method has been improved above, and it is only the first time.

// Generate an instance when using it, improve efficiency!

IF (instance == null)

Instance = new singleleton ();

Return Instance;}

}

Other forms:

Define a class, its constructor is private, all methods are static.

It is generally considered that the first form is more secure.

33thtable and havehmap

HashTable inherits from the Dictionary class, and HashMap is an implementation of Map Interface introduced by Java1.2.

Hashmap allows null as a key or value of Entry, and hashtable is not allowed

Also, Hashmap removes the HashTable's Contains method, changed to ContainsValue and Containskey. Because the Contains method is easy to cause misunderstandings.

The biggest difference is that the HashTable method is Synchronize, and hashmap is not,

When multiple threads access HashTable, you don't need to synchronize it for its method, and have HashMap

It is necessary to provide external synchronization.

Hash / rehash algorithms used by HashTable and Hashmap are probably, so performance will not have a big difference.

********************* The first person's supplement abcdhy (Cheng Xu) ***************** ******************

The answer has a problem: !!! I will list some controversial: Second, Anonymous Inner Class (anonymous internal class) Can IMPLEMENTS (Implement) INTERFACE (interface)?

Anonymous internal classes can be extends other classes, this I have tested.

Eleventh, short s1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong?

Short S1 = 1; S1 = 1 is not correct. Where Short S1 = 1 This sentence will be wrong because 1 is int

Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference?

The elements in the set cannot be repeated, then use the iterator () method to distinguish whether you are repeated. Equals () is the judgment of whether two SETs are equal. This answer is incorrect, and the set distinguishes the repeating element is implemented.

Twentydays, after a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?

No, a Synchronized method of an object can only be accessed by one thread.

This also has problems. After a thread enters an Synchronized method of an object, this thread has the synchronous lock of the object. Other threads cannot enter the other synchronization method of this object, as other threads do not receive the synchronization lock of the object. However, other threads can enter other non-synchronous methods of this object, because entering the non-synchronous method, no simultaneous lock is required.

The second nine, the two object values ​​are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?

No, there is the same Hash Code. According to Java coding specification, X.Equals (y) == True, hash code is dominated, but this is just a coding specification, and it can be done when it is programmed, and it can run normally.

Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery?

It is a value transfer. The Java programming language is only passed by the value. When an object instance is transmitted to the method as a parameter, the value of the parameter is a reference to the object. The content of the object can be changed in the called method, but the reference to the object will never change.

Halo, actually said: The reference to the object will never change, what is the reference to the object, is the memory address (UINT), how to change. The pass value is a biography, which is for "objects". "Object" object Quote "is: passing the value or the biography, meaning ??

I briefly looked at it. Everyone can discuss it together!!

******************** The third person's answer abcdhy (Cheng Xu) ***************** ******************

First, talk about the difference between Final, Finally, Finalize.

Too easy

Second, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)?

All can

Third, Static Nested Class and Inner Class are different, the more you say, the better.

Static class does not exist and the association of the periphery

The difference between fourth, & and &&.

Too easy

Fifth, the difference between HashMap and HashTable.

Too easy

Sixth, the difference between Collection and Collectes. Too simple: the former is an interface, or an application class

Seventh, when do you use Assert.

Debug

Eighth, what is GC? Why have GC?

Needless to say

Ninth, string s = new string ("xyz"); created a few String Object?

Nance, of course, don't say that the reference is an object

Tenth, Math.Round (11.5) is equal to how much? Math.Round (-11.5) is equal?

I am dizzy.

Eleventh, short s1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong?

The former can't compile

12. What is the difference between SLEEP () and WAIT ()?

The former sleeps yourself, the latter is waiting for others

Thirteenth, have Java goto?

Keyword, no

Fourteenth, there is a length () method for arrays? String has a length () method?

Array is attribute, String is a method

Fifteenth, the difference between overload and override. Can OVERLOADED methods change the type of return value?

Overload and cover

Tenth, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference?

How to use ==?

Seventest, give me a Runtime Exception you most often.

NullPointerException

Eighteenth, what is the difference between ERROR and EXCEPTION?

Error and abnormal, severe severe

Near 10th, List, SET, MAP inherits from a Collection interface?

MAP is not

Ten, what is the difference between Abstract Class and Interface?

This is also asked?

Second Eleventh, abstract can be static at the same time, whether it can be native at the same time, is it SYNCHRONIZED?

I guess: can't

Typographic, whether the interface can inherit the interface? Does the abstract class implement (IMPLEMENTS) interface? Does the abstract class can inherit the physical class (Concrete Class)?

of course can

On the thirteenth, starting a thread is Run () or start ()?

Start

24. Is the constructor CONSTRUCTOR can be Override?

A bit ridiculous

The second fifteenth, can you inherit the String class?

NOWAY

Twentydays, after a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?

of course can

27. There is a Return statement in try {}, then the code in finally {} in this try will not be executed, when is executed, before returnome or after?

Of course it is Return

Chapter 28. Program: 2 Multiply 8 equal to?

I have a test INT SB = 2 << 3;

The second nine, the two object values ​​are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?

This problem is SB asked SB.

Can have different havehcode, but Java does not recommend this

Thirty, when an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery?

This question is SB asked SB

It is a pass value, but this value is a reference

Thirty-first, whether SWTICH can act on Byte, whether it can act on long, can it work on String? INT

Thirty-two, programming questions: write a singleleton out

Double Check is invalid

************************************************************************************************** *****************

I think Finally should run before returnome.

Such statements are often used when obtaining database connections

Try {

CONNECTION = dbpool.get ();

.......

// Todo

}

Catch (SQLException E)

{

// Todo

}

Finally

{

Try {

IF (Connection! = NULL)

Connection.Close ();

}

Catch (SQLException E)

{

Connection = NULL;

// Todo

}

}

The purpose of writing this is whether the connection of the database should be closed regardless of what happens.

Twenty-seven this is very troublesome:

Class testfinally

{

Public static void main (string [] args)

{

System.out.println (TEST ());

}

Public static int test () {

INT i = 0;

Try {

System.out.println ("try");

Return I;

}

Finally {

System.out.println ("FINALLY");

i = 1;

Return I;

}

}

}

Look at the results?

How can you measure this? This way you can only prove

System.out.println (TEST ()); this statement is in System.out.Println ("INTO Finally"); this statement is executed, and system.out.println (Test ()) is included in this sentence Two steps, the first step Test () can be understood as return, the second step is printed, in fact, FINALLY is executed in these two steps, why not take my example to try?

Public static int test () {

INT i = 0;

Try {

Return I;

}

Finally {

i = 1;

System.out.println (i);

}

}

Zstzah (highlighting) is right, Finally is to be executed anyway!!

But I tested it, FINALLY is executed before return.

Test code:

Public class a {

Public static void main (String [] args) {

System.out.println (TEST ());

}

Public static int test () {

INT i = 0;

Try {

Return I;

}

Finally {

System.out.println ("INTO Finally");

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-89496.html

New Post(0)