Good programmers Share: Java interview questions FAQ

  Good programmers Share: Java interview questions frequently asked questions, facing a huge java interview exam, want brushing seems unlikely, need to accumulate little by little, and today we share some Java interview questions FAQ


1, java will be a memory leak it, please describe.


  A: Yes; there is an object useless but reachable, these objects can not be recovered GC, resulting in the cost of memory resources.


2, the difference between static variables and instance variables?


  A: Static variables are also known as class variables, there are owned by the whole class, it does not depend on an object, can be accessed directly through the class name; and instance variables must be dependent on an instance, it can only be accessed through an object.


3, can make calls to non-static method from within a static method?


  A: No, if it contains an object method (), initialize the object is not guaranteed.


4, write clone () method when, usually have a line of code, what is?


  A: Clone have default behavior: super.clone (), he was responsible for the creation of space of the correct size, and bit by bit copy.


5, GC is the What? Why should there be GC?


  A: GC is a garbage collection means (Gabage Collection), memory handling is where programmers prone to problems, and forget or false memory recovery program will lead to instability or even system crashes, GC functionality provided by Java can automatically monitor objects exceeds the scope so as to achieve the purpose of automatic recovery of memory, Java language does not provide a method for displaying the operation to release the allocated memory. Java programmers do not have to worry about memory management, because the garbage collector will automatically be managed. One way to request garbage collection, you can call the following: System.gc () or Runtime.getRuntime () gc ()..


6, the working mechanism to say what is the data connection pool?


  A: The connection pool will create a certain amount of time J2EE server startup, and has remained less than this number of pooled connections. Needs to connect client program, the pool driver returns a pool of unused connection and denoted as busy. If no connection is idle, the driver on the new pool certain number of connections, the number of new connections have decided to configuration parameters. When the call is completed using a connection pool, pool table driver this connection referred to as idle, other calls can use this connection.


7, EJB activation mechanism?


  A: In the Stateful Session Bean as an example: its size determines the number of Bean Cache memory instances that can exist at the same time, according to MRU or NRU algorithm, instance migration between activated and deactivated states, the mechanism is activated when a client calls when a business method EJB instance, if the corresponding EJB Object is not bound Bean instance find themselves from their corresponding deactivation Bean store (storage instance via serialization mechanism) reply (activated) in this instance. It calls the corresponding method ejbPassivate ejbActive and former state transition.


Guess you like

Origin blog.csdn.net/weixin_33698823/article/details/91398236