Interview Series - 2019 125 common pen java interview questions summary (a)

1. Abstract:
Abstract is to ignore those aspects of a topic unrelated to the current target, in order to more fully pay attention to aspects related to the current target. Abstract does not intend to know all the

Problem, but only select some of them, being not part of the details. Abstract includes two aspects, one procedural abstraction, and second, data abstraction.

2. Inheritance:
Inheritance is linked hierarchical model class, and to allow and encourage the reuse of classes, it provides a clearly stated in common. A new class of objects can be derived from existing classes, this process is called class inheritance. The new class inherits the properties of the original class, the new class known as the original class of the derived class (subclass), while the original class is called the base class for the new class (parent class). A derived class can inherit methods and instance variables from its base class, and the class may modify or add new method makes it more suitable for particular needs.

3. Package:
packaging and is to process packet enclosed, access to the data only through a defined interface. Object-oriented computing began in the basic notion that the real world can be represented as a series of fully autonomous, encapsulated objects that access other objects through a protected interface.

4. Polymorphism:
polymorphism refers to allow objects of different classes respond to the same message. Polymorphisms include parametric polymorphism containing polymorphism. Polymorphism flexible language, abstract, behavior sharing, code-sharing advantages of a good solution to the problem of the application function of the same name.

5, String is the most basic data type?
Basic data types include byte, int, char, long, float, double, boolean and short.
java.lang.String class is final, and therefore can not inherit this class, the class can not be modified. In order to improve efficiency to save space, we should use StringBuffer class

6, int and Integer What is the difference
Java offers two different types: primitive types and reference types (or built-in type). Int java type of raw data, Integer int is to provide a package java classes. Providing the Java class for each primitive type package.
Primitive type package type
Boolean Boolean
char Character
byte Byte
Short Short
int Integer
Long Long
a float the Float
Double Double
reference types and primitive types of behavior is completely different, and they have different semantics. Reference types and primitive types have different characteristics and uses, they include: the size and speed of this type to which type of data structure is stored, when the designated reference types and primitive types used as an example of a class of data The default values. The default value is null object reference of the instance variables, and the default values of the original type of instance variables with their type.

7, String and StringBuffer distinction
JAVA platform provides two classes: String and StringBuffer, which can store and manipulate strings, i.e., character data comprising a plurality of characters. This class provides a numeric string String immutable. This class provides the string while StringBuffer be modified. When you know you want to change the character data when you can use StringBuffer. Typically, you can use StringBuffers to dynamically construct character data.

8. What are the similarities and differences with the general exception runtime exception?
Anomalies indicate abnormal status during program execution may appear abnormal represent runtime virtual machine abnormal usual operation may be encountered, it is a common run-time error. When abnormal, but does not require a statement uncaught when running java compiler must request a declaration of non-operational throw exceptions that may occur.

9, say Servlet life cycle, and say Servlet and CGI difference.
Servlet is server instantiated, the container runs its init process runs its service method when a request arrives, the service method of automatically sending doXXX method of operation corresponding to the request (doGet, doPost), etc., when the server decides examples of the destruction when calling its destroy method.
The difference is that with cgi servlet in the server process , which by multiple threads to run its service method way, an instance can service multiple requests, and the examples are generally not destroyed, CGI has produced a new process for each request, after the service is completed destroyed, so efficiency is lower than the servlet.

10, say ArrayList, Vector, and storage performance characteristics LinkedList
ArrayList and Vector data is stored using an array, the array element number is greater than the actual data is stored so as to increase and insert elements, which allow the element directly indexed by serial number, but insert element array elements involved in movement, etc. of memory operations, the index data fast and slow insert data, Vector since a synchronized method (thread- safe ), typically on the performance than ArrayList difference, and LinkedList bidirectional linked list implementation stored, indexed by serial number data before the need to traverse to or after, but only before and after the record of this can insert the data item, the insertion speed.

11, EJB technology which is based implementation? And tell the difference between SessionBean and EntityBean, the difference StatefulBean and StatelessBean of.
 Including EJB Session Bean, Entity Bean, Message Driven Bean, based on JNDI, RMI, JAT and other technology.
SessionBean the J2EE application server is used to complete a number of business operations, such as access to a database , to call other EJB components. EntityBean is used to represent the application system data is used.
For clients, SessionBean is a non-persistent object that implements some business logic running on the server.
For the client, the EntityBean is a persistent object that represents a view of an entity objects stored in a persistent memory, or implemented by a conventional enterprise application entity.
Session Bean also can be subdivided into Stateless and Stateful Session Bean Session Bean, Session Bean both the system logic may be put into execution method, except that the Stateful Session Bean can record the caller's state, thus generally He says, a user will have a corresponding Stateful Session Bean entities. While Stateless Session Bean is logical components, but he is not responsible for recording user status, which means that when a user when a call Stateless Session Bean, EJB Container does not look for a specific Stateless Session Bean entities to perform this method. In other words, it is likely a number of users in the implementation of a Stateless Session Bean's methods, it would be the same Bean's Instance in execution. , Stateful Session Bean from the comparison in terms of memory and Stateless Session Bean, Stateful Session Bean J2EE Server will consume more memory, however Stateful Session Bean advantage of it is that he can maintain the user's state.

12, Collection and Collections of the difference. 
Collection is a set of interfaces parent class, inheritance and his main interface Set and List.
The Collections is help for a class set of classes, he offers a series of static methods to achieve a variety of search collection, sorting, and so thread-safe operations .

13 difference, and & & &. 
Is the bitwise operators &, represents bitwise AND, && is the logical operator, and represents a logical (and).

14 difference, HashMap and Hashtable of. 
 Hashtable HashMap is a lightweight implementation (non-thread-safe implementation), they have completed the Map interface, the main difference is that HashMap allows null (null) key (key), due to non-thread-safe, Hashtable may be higher than on efficiency.
HashMap allows null as a key entry or the value, and not allowed Hashtable.
HashMap Hashtable contains methods removed, replaced containsvalue containsKey. Because it contains could easily lead to misunderstanding. 
Dictionary class inherited from Hashtable, and HashMap is a realization of Java1.2 introduction of the Map interface.
The biggest difference is, Hashtable method is Synchronize, while HashMap is not, when multiple threads access Hashtable, do not need to sync method for its realization, but it is necessary to provide them HashMap external synchronization. 
Hash / rehash algorithms using Hashtable and HashMap are about the same, so performance will not be very different.

15 except final, finally, finalize the. 
final declaration for properties, methods, and classes, attributes can not be changed, respectively, the method can not be overwritten, the class can not be inherited.
finally exception handling part of sentence structure, means always executed.
finalize is a method of the Object class, at the time of execution of the garbage collector calls this approach is subject to collection, can override this method to provide additional resources when recycling garbage collection, such as closing files.

16, sleep () and wait () What is the difference? 
sleep is a method of the Thread class (Thread), leading to this thread to suspend the specified time, the opportunity to perform to the other thread, but monitoring status remains, to the post will be automatically restored. Call sleep will not release the object lock.
wait is a method of the Object class, object calls this method leads to wait this thread to give the object lock, waiting to enter the pool waiting for a lock for this object, and only issued after notify method (or notifyAll) for this thread to lock this object before entering the target pool to get ready object lock into operation.

17, Overload and Override the difference. Overloaded methods can change the type of return value?
Rewrite Overriding and overloading Overloading methods are different manifestations of Java polymorphism. Overriding rewrite polymorphism of performance between a parent class and subclass, overloading Overloading is a manifestation of a polymorphism. If you define a method in a subclass and his father have the same name and parameters, we say that the method is rewritten (Overriding). Subclass of the object of using this method, the call definition subclass, it, the parent class is defined as being "blocked" a. If the method of the plurality of the same name defined in a class, or which have a different number of parameters or different parameter types, called overloaded methods (Overloading). Overloaded methods can change the type of the return value.

18, error and exception What is the difference?
Error represents a serious problem in the case of recovery is not impossible, but very difficult. For example, memory overflow. Program can not be expected to handle such a situation.
exception shows a design or implementation issues. In other words, it means that if run properly, the situation never happened.

19, synchronous and asynchronous What are the similarities and differences in the circumstances under which they were? for example.
If data will be shared between threads. For example, it may be read by another thread after the writing of data, or data is being read may have been written by another thread, then the data is shared data, access must be synchronized.
When the application calls the method takes a long time to execute on the object, and do not want the program to wait for the process to return, you should use asynchronous programming, using asynchronous approach in many cases tend to be more efficient.

20, abstract class and interface What is the difference?
There is a statement of the method to achieve it without the class is called abstract class (abstract class), which is used to create a manifestation of some basic behavior of the class, and as such a statement but we can not achieve this kind of situation in the class. You can not create instance of abstract class. However, you can create a variable whose type is an abstract class and points it to a specific sub-class. Constructor can not have abstract or abstract static methods. Abstract subclass of class to provide implementation for all of their abstract methods of the parent class, it is an abstract class. Instead, the method is implemented in a subclass. We know the behavior of other classes can implement these methods in the class.
Interface (interface) is a variant of the abstract class. In the interface all methods are abstract. Multiple inheritance can be obtained by implementing this interface. All interface methods are abstract, not a program body. The interface can only define static final member variables. And subclasses to achieve a similar interface, not inherit behavior from the interface definition in addition to the realization. When implementing special class interface, which the definition of (the procedure of giving) all such interface. Then, a method that may be implemented on any call interface of the object class interface. As an abstract class, which allows the use of interface name as the reference variable type. The usual dynamic binding will take effect. Reference can be converted to interface type, or conversion from interface type, instanceof operator can be used to determine whether an object class implements the interface.

21, heap and stack What is the difference.
Stack is a linear collection, add and delete elements should be completed in the same period. Stack processed according to the LIFO method.
Heap is an integral element of the stack

22, forward and redirect the difference between
forward is the server requests a resource server URL to directly access the target address, the response content that URL to read over, and then put these elements and then distributed to the browser, the browser I did not know the content transmitted from the server is going to come from, so it's address bar or the original address.
redirect server is based on logic, send a status code that tells the browser to re-request the address, in general, the browser will just re-request with all the parameters of the request, so the session, request parameters can get.

23, EJB and JAVA  BEAN difference?
Java Bean is reusable components, and on the Java Bean and not strictly regulated, in theory, any Java class can be a Bean. But usually, since the Java Bean is created by the container (such as Tomcat), so the Java Bean should have a no-argument constructor, and typically also implements Serializable Java Bean to Bean persistence of the implement. Java Bean actually equivalent to Microsoft COM model of local processes within a COM component, it can not be accessed across processes. Enterprise Java Bean is equivalent to DCOM, that is distributed components. It is Invocation (RMI) technology based on Java's Remote Method, the EJB can be remote access (across processes, across the computer). But EJB must be deployed in such Webspere, such a container in WebLogic, EJB clients never directly access the real EJB components, but by its container access. EJB containers EJB component agent, EJB components are created and managed by the container. Customers to access real EJB components through the container.

24, Static Nested Class and Inner Class differences. 
Static Nested Class is declared static (static) inner class, it can not rely on an external class instance is instantiated. The usual inner class needs to be instantiated in the outer class is instantiated.

25, JSP difference between dynamic and static INCLUDE INCLUDE is?
INCLUDE with dynamic jsp: include action to achieve <jsp: include page = "included.jsp " flush = "true" /> It always check the changes contained in the file, suitable for containing dynamic pages, and can be parameterized.
Static INCLUDE implemented include pseudo-code, will not check the changes contained in the file, suitable for containing static page <% @ include file = "included.htm "%>

Guess you like

Origin www.cnblogs.com/juihai/p/11102138.html