Java Interview Set (2)

xiaoxiao2021-03-06  18

31, EJB includes (sessionbean, entitybean) says their life cycle, and how to manage transactions? The lifecycle of the STASSIONBEAN: STATELESS session bean is determined by the container. When the client issues a request to establish a bean instance, the EJB container does not have to create a new bean instance for client call, but a place to find a present Some instances are provided to the client. When the client calls a stateful session bean for the first time, the container must immediately create a new bean instance in the server, and related to the client, after this client calls the Stateful session bean method, the container will assign the call to This client is associated with a bean instance. EntityBean: Entity Beans can survive relatively long time, and status is continuous. Entity Beans has always survive as long as the data in the database exists. Not in accordance with the application or service process. Even if the EJB container crashes, Entity Beans is also survived. The Entity Beans life cycle can be managed by the container or Beans. EJB is implemented by the following technical management practices: Object Management (OMG) Object Service (OTS), Sun Microsystems Transaction Service (JTS), Java Transaction API (JTA), Development Group (X / Open) XA interface. 32. What are the application servers? BEA WebLogic Server, IBM WebSphere Application Server, Oracle9i Application Server, JBoss, Tomcat33, gives me a Runtime Exception you most often seen. 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, UNSUPPORTEDOPERATIONEXCEPTION34, whether the interface can inherit the interface? Does the abstract class be implemented? 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. 35, List, SET, MAP inherits from the Collection interface? List, SET is not 36, how is the working mechanism of the data connection pool? J2EE server starts a certain number of pool connections, and maintain a lot Connects to this number of pools. When the client program needs to be connected, the pool driver returns an unused pool connection and exposes its expression as busy. If there is currently no idle connection, the pool driver has created a certain number of connections, and the number of new connections has configured parameters. When the pool connection call is used, the pool driver is idle, and this connection can be used in other calls. 37. Is Abstract's Method can be static at the same time, whether it is native at the same time, is it possible to be synchronized? Can't 38, there is a length () method? String Is there a length () method? The array does not have Length () method, with the properties of the length. String has a length () method. 39, 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 element in the set cannot be repeated, then use Iterator () The method is distinguished from whether it is 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. 40, whether the constructor can be ca not inherited by the Override® constructor constructor, so Overriding cannot be overridden, but Overloading can be overloaded. 41, can you inherit the String class? The String class is that Final is not inherited. 42. If SWTICH can act on Byte, whether it can act on long, whether it can act 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. 43, Try {} has a return statement, then the code keeps in finally {} after this try, will not be executed, when is executed, before returnome or after it will execute, execute before returnrate. 44. Programming: 2 multiply 8 equal to a few? 2 << 345, two object values ​​(x.equals (y) == true, but there can be different Hash Code, This sentence is wrong? Is wrong, there is the same hash code. 46. ​​After 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? Is a value transfer. Java programming languages ​​only value pass parameters. 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. 47. After a thread enters an SYNCHRONIZED method of an object, other methods of other threads can enter this object? No, one Synchronized method of an object can only be accessed by one thread. 48. Program: Write a Singleton out. 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 state of static private, instantoneation, and GetInstance through a public Method Get a reference to it, then calls it. Public class singleton {private singleton ()} // define one instance in itself, is it very strange? / Note This is private only for internal calling private static singleton instance = new singleton (); // here provides a static method for external access to this Class, you can directly access public static singleton getInstance () {return instance;}} The second form: public class singleleton {private static singleleton instance = null; public static synchronized singleton getInstance () {// This method is improved above, do not have to generate an object each time, only the first time // Generate an instance and improve efficiency! IF (instance == null) instance = new start;}} Other forms: Define a class, its constructor is private, all methods are static. It is generally considered that the first form is to be more securely 49, Java interface, and the virtual class of C . Since Java does not support multi-inheritance, it is possible to use a class or object to use a method or attribute in several classes or objects, and existing single inheritance mechanisms cannot meet the requirements. Compared to inheritance, the interface has higher flexibility because there is no implementation code in the interface. When a class implements an interface, this class is to implement all methods and properties in the interface, and the properties in the interface are all public static below, all methods are public. Public. A class can implement multiple interfaces. 50. Simple principle and application of exception handling mechanism in Java. When the Java program violates the semantic rules of Java, the Java virtual machine will represent an error as an exception. Violation of semantic rules include 2 cases. One is a semantic check in the Java class library. For example, the array subscript can trigger indexoutofboundsexception; nullpointerException will be triggered when accessing null objects. Another situation is that Java allows programmers to extend this semantic check, and programmers can create their own exceptions and freely choose to trigger exceptions with throw keywords. All exceptions are subclasses of java.lang.thowable. 51, the advantages and principles of garbage collection. And consider 2 recycling mechanisms. A significant feature in the Java language is to introduce the garbage collection mechanism, which makes the problem of the most headache of C programmers, making the Java programmers no longer need to consider memory management when writing programs. Since there is a garbage collection mechanism, the object in Java no longer has the concept of "scope", and only the reference to the object has a "scope". Garbage recycling can effectively prevent memory leaks, effective use of memory that can be used. The garbage collector is usually operated as a separate low-level thread. In the case of unpredictable objects that have been died or have not used for a long time for a long time for a long time, the programmer cannot call the garbage collector in real time. Object or all objects are garbage collection. The recycling mechanism has a replica collection of garbage collection and marking garbage recovery, incremental garbage recovery.

52. Please tell us how the thread synchronization you know. Wait (): Make a thread in the waiting state and release the LOCK of the object held. Sleep (): Make a running thread in sleep state, is a static method, call this method to capture InterruptedException exceptions. NOTIFY (): Wake up a thread in a waiting state, note that when this method is called, it is not exactly the thread that is awakened, but is determined by the JVM which thread is awake, and is not pressed. AllNotity (): Wake all threads in the waiting state, not to give all the locks of all awakening threads, but let them compete. 53, what are your collection? Main method? The most commonly used collections are LIST and MAP. The specific implementation of List includes ArrayList and Vector, which are variable-sized lists, which are more suitable for build, store, and operate any type of objects for any type object. List is suitable for use in value to access elements. Map provides a more versatile element storage method. The MAP set class is used to store element pairs (called "keys" and "value"), where each key is mapped to a value. 54. Describe the principle mechanism of the JVM load Class file? The load in JVM is implemented by ClassLoader and its subclass, Java ClassLoader is an important Java runtime system component. It is responsible for finding and putting a class file at runtime. 55. Can a Chinese Chinese character can be stored in the CHAR type variable? Why? Can definition becoming a Chinese, because Java is encoded in Unicode, a char accounts for 16 bytes, so putting a Chinese is no problem 56, multi-thread There are several implementation methods, what is it? Synchronize several implementation methods, what is the multi-threaded implementation method, which inherits the Thread class and implementation of the implementation of the Runnable interface synchronization, Synchronized, WAIT and NOTIFY57, JSP built-in objects and methods. Request represents the HTTPSERVLETREQUEST object. It contains information about the browser request and provides a number of methods for obtaining cookie, header, and session data. Response represents the HTTPSERVLETRESPONSE object and provides several methods for setting the response to the browser (such as cookies, header information, etc.) OUT objects are an instance of javax.jsp.jspwriter, and provide several ways to make you Used to return the output result to the browser. PageContext represents a javax.servlet.jsp.pageContext object. It is an API for convenient access to various range spaces, servlet-related objects, and wraps a generic Servlet related feature. Session represents a request Javax.Servlet.http.httpSession object. Session can store the user's status information Applicat represents a javax.servle.ServletContext object. This helps find information about the Servlet engine and the servlet environment represents a javax.servlet.servletConfig object. This object is used to access the initialization parameters of the servlet instance. Page Represents a servlet instance 58 generated from this page, the basic concept of the thread, the basic state of the thread, and the state of the relationship between the state, in the program execution, the execution unit of the program code can be executed, each program is at least A thread, that is, the program itself. There are four states in Java, respectively, running, ready, hang, and end.

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

New Post(0)