Java Interview Information

xiaoxiao2021-03-06  42

Java aspect

1 What are the object-oriented characteristics?

2 STRING is the most basic data type?

3 INT and Integer What is the difference?

4 String and StringBuffer difference

5 What is the difference between abnormality at runtime?

An abnormality indicates the abnormal state of the program during operation, and the runtime exception indicates an exception that may be encountered in the usual operation of the virtual machine is a common run error. The Java compiler requires that the method must declare that the possible non-running abnormality, but does not require a statement that the abnormality that is not captured.

6 Speak some common class, package, interface, please give 5

7 Say the storage performance and feature of ArrayList, Vector, LinkedList

All ArrayList and Vector are stored in an array. This array element is larger than the actual stored data to increase and insert an element, which allows direct sequence index elements, but inserts an element to involve memory operation such as array elements, so index data Fast and inserted, Vector due to the use of the Synchronized method (thread security), usually more arraylist, and LinkedList uses two-way linked lists to store, and sequence index data needs to be forwarded or rearward, but inserting data only You need to record the front and rear items of this item, so the insert is faster.

8 Design 4 threads, two threads increase 1 each time, and two threads are reduced each time. Write the program.

The following procedure uses internal classes to implement threads, and no order issues are not considered when J is reduced.

Public class threadtest1 {

Private int J;

Public static void main (string args []) {

Threadtest1 TT = New Threadtest1 ();

INC = TT.NEW INC ();

Dec dec = tt.new dec ();

For (int i = 0; i <2; i ) {

Thread T = New Thread (INC);

T.Start ();

T = New Thread (DEC);

T.Start ();

}

}

Private synchronized void inc () {

J ;

System.out.println (thread.currentthread (). GetName () "- inc:" J);

}

Private synchronized void dec () {

J -;

System.out.println (thread.currentthread (). GetName () "- DEC:" J);

}

Class incblements runnable {

Public void run () {

For (int i = 0; i <100; i ) {

INC ();

}

}

}

Class Dec Implements Runnable {

Public void run () {

For (int i = 0; i <100; i ) {

DEC ();

}

}

}

}

9. The built-in object and method of JSP.

Request 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 Response represents the HTTPServletResponse object and provides several methods for setting the response to the browser (such as cookies, header information, etc.) OUT OUT objects are an instance of javax.jsp.jspwriter, and provide several ways You can use to return the output results to your browser. PageContext 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 session represents a request Javax.Servlet.http.httpsession object. Session can store the status information of the user Application Applicat Indicates a Javax.Servlet 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 Page Represents a servlet instance 10 generated from this page. Writing communication with the Socket communication, requiring the customer to return the same data after sending data.

See the Socket Communication in the course.

11 Say the life cycle of the servlet and say the difference between servlet and CGI.

After the servlet is instantiated by the server, the container runs its init method, the request is reached, the service method is automatically dispatched with the DOXXX method (Doget, DOPOST) corresponding to the request, and calls its Destroy when the server decides to destroy the instance. method.

The difference from the CGI is that the servlet is in the server process, which runs its service method by multithreading, and an instance can serve multiple requests, and its instance is generally not destroyed, and CGI has a new process for each request. After the service is completed, it is destroyed, so it is less efficient than servlet.

12.EJB is based on which technologies are implemented? And say the difference between SessionBean and EntityBean, the differences of Statefulbean and STATELESSBEAN.

13. EJB includes (sessionbean, entitybean) says their life cycle, how to manage transactions?

14. What is the working mechanism of the data connection pool?

15 Synchronous and asynchronous and asynchronous, use them in what circumstances? for example.

16 What are the application servers?

17 What are your collections you know? Main method?

18 Give you: Driver A, Data Source Name B, the user name is C, the password is D, the database table is T. All the data of the table T is retrieved with JDBC.

19. Say how to make a pagination in the JSP page?

The page needs to be saved the following parameters:

Total number of lines: According to the SQL statement, the total number of banks

Variety of lines per page: set value

Current page: request parameters

The page calculates the number of rows of the current page according to the number of current pages and the number of rows per page, and the positioning result is set to this line, and the result set takes out the number of rows of rows per page.

Database:

1. Different storage procedures for stored procedures and functions are a collection of user-defined series of SQL statements, involving tasks for specific tables or other objects, users can call stored procedures, and functions are usually the customized method, which receives parameters and Returns a certain type of value and does not involve a specific user table. 2. What is the transaction? The transaction is a series of operations performed as a logical unit, and a logical work unit must have four properties, called ACID (atomic, consistency, isolation and persistence) attributes, only this can become a transaction:

Atomic transactions must be atomic working units; for their data modifications, they are either executed, or they are not implemented.

When the consistency is completed, all the data must be consistent. In the relevant database, all rules must be used to modify the transaction to maintain all data integrity. At the end of the transaction, all internal data structures (such as B tree indexes or bidirectional linies) must be correct.

Isolation is modified by concurrent affairs to be isolated from any other concurrent business. Transaction View the status of data when data is displayed, or another concurrent transaction modifies its previous state, or another transaction modifies the state after it, the transaction does not view the data of the intermediate state. This is referred to as serialization because it can reload the starting data and replay a series of transactions so that the status at the end of the data is the same as the original transaction.

After the durability transaction is completed, its impact on the system is permanent. This modification will remain maintained even if there is a system failure.

3. The role of the cursor? How do you know that the cursor has arrived at the end?

The cursor is used for the line of positioning result set, and by judging that the global variable @@ fetch_status can determine whether the final change is usually, this variable is usually not equal to 0 to indicate an error or finally.

4. The trigger is divided into an existing trigger and post-event trigger, which triggers and distinctions. What is the difference between statement level trigger and row trigger.

The prior trigger is running before the trigger event occurs, and after the event is running after the trigger event occurs. Usually the prior trigger can get the event before and the new field value.

Statement-level triggers can be executed before or after execution of statements, while the row triggers each row that triggered in the trigger.

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

New Post(0)