No. 10 11.29 interview questions

And the contrast between the dom4j sax: a first question

dmo4j not suitable for parsing large files, because it is at once the file is loaded into memory, all memory overflow may occur; sax is based on an event to parse xml, so it can parse large xml file. Precisely because of this, it is possible to xml dom4j flexible CRUD and navigation, but not so strong sax flexibility; so sax is often used to parse large xml file, and to some flexible (crud) to xml file operating on the use dom4j.

The second question: the difference between final, finally, finalize the three

1.final is a modifier
when the final modified a variable, variable becomes a variable, he can not be a secondary assignment.
When the final modified variable as a static variable (ie, when modified by a static), it must assign a value to a variable in a statement this time.
When the final modification, the method can not be rewritten.
When the final modified class, which can not be inherited.
final abstract class can not be modified, because there will be an abstract class abstract class that implements the method needs child.
final interfaces can not be modified, because there is a need for class implement the interface implementation.
2.finally
finally only the try / catch statement used in combination, the finally block statement will be executed.
3.finalize
the Finalize method is a belonging java.lang.object class, finalize () method is part of (garbage collector garbage collection) operation mechanism of GC, finalize () method is called when the object is to clean it belongs in the GC.

Third question: java What is multi-thread synchronization

In multithreaded programs, the synchronization can be controlled to control access to shared resources. Without synchronization, when a java thread to modify a shared variable, another thread is using or updating a variable, so easily lead to procedural errors.

Fourth Question: Explain several ways to achieve multi-threaded? What is the difference?

Java thread can implement Runnable or Thread class inheritance to achieve, when are you going to multiple inheritance, preference implement Runnable. Difference: Start method is not the same. Thread1 inheritance, Thread2 implement Runnable, then start a thread can use Thread1 new Thread1 (). Start (), and then start Thread2 thread new Thread (new Thread2 ()). Start ().

The fifth question: Thread.start () and Thread.run () What is the difference?

run () method: Call the object's Runnable thread within the run () method may be repeated this call.
start () method: Start a thread calls the run () method of the Runnable object, this can not start a thread.

Question 6: What is deadlock

Deadlock is two or more threads are blocked infinite, each waiting for the required resources between threads. This may occur when two threads attempt to acquire a lock other resources, and each thread has to wait for the release of other resources into a wireless lock, unless a user process is terminated. On JavaAPI, the thread deadlock can occur about the situation.
1. When the two threads call each other the Thread.join ()
2. When two sync blocks nested threads, a thread holds a thread required additional lock, each other is blocked waiting deadlock is likely to occur.

Q7: What is the thread starvation, what is livelocks?

Thread starve: refers to a process that can be run despite survives, but was ignored indefinitely scheduler, scheduling situation can not be executed.
Livelock: refers to the task or performer is not blocked, because some conditions are not met, resulting in repeated attempts, failed, attempt failed. Live locks and deadlocks difference is that the living entity is in lock state is constantly changing, so-called "living" entity representation in deadlock waiting; live lock can unlock their own, but can not deadlock.

Q8: Java threads in the four states are what?

Java threads in four states: New, ready, running, blocking

Ninth title: scope modifier

private default protected public
The same class can can can can
Class in the same package can can can
Different packages subclass can can
Different classes of packets can

Question 10: == and equals the difference

Difference: == comparison operation is the value of two variables are equal, the two variables are the same as the address stored in the stack, i.e. the stack is the same as the contents of a reference to variables represented. Whether two variables equals operation represented by reference to the same object, i.e., the content of the stack is the same.

If wrong, please correct me! ! !

Published 28 original articles · won praise 16 · views 592

Guess you like

Origin blog.csdn.net/qq_37881565/article/details/103317340