Java Huawei Interview

xiaoxiao2021-03-06  40

What are the most basic data types? 3 INT and Integer What is the difference between 4 string and StringBuffer? Is there a difference in the 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 raise 5 7 to say that ArrayList, Vector, LinkedList's storage performance and features ArrayList and Vector are stored in an array mode, and the number of elements is greater than the actual stored data. In order to increase and insert elements, they all allow direct sequence number index elements, but inserted into memory operations such as array elements, so the index data is fast and the data is slow, and the vector is used by the Synchronized method (thread security), usually Compared to ArrayList, the LinkedList uses a two-way linked list to store, pressing the number index data to perform forward or rear traversal, but only the front and rear items of this item are required when inserting data, so the insertion speed 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 (); incin = tt.new inc (); 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 incmplements 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.Servle.ServletContext object. This helps find information about the Servlet engine and the servlet environment

Config config 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? Page needs to save the following parameters: Total line number: get the number of lines per page according to the SQL statement: Set value Current page: Request parameter page According to the current number of pages and each page The number calculates the number of lines of the first line of the current page. The positioning result set is set to this line, and the result set takes out the line of the number 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 attributes, called ACID (atomic, consistency, isolation, and persistent) attributes, only this can become a transaction: atomic transaction It must be an atomic work unit; for its data modification, it is either executed, or all do not execute. 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-82799.html

New Post(0)