A common interview question is: (How many answers can you answer ?)

Source: Internet
Author: User

Java
1. What are the aspects of object-oriented features?
2 is string the most basic data type?
3 what is the difference between int and integer?
4 differences between string and stringbuffer
5. What are the differences between runtime exceptions and general exceptions?
An exception indicates an abnormal state that may occur during the running of the program. An exception indicates an exception that may occur during common operations on the virtual machine. It is a common running error. The Java compiler requires that methods must declare and throw possible non-runtime exceptions, but do not require that they throw uncaptured runtime exceptions.
6. You can name five common classes, packages, and interfaces.
7. Specify the storage performance and features of arraylist, vector, and sorted list.
Both arraylist and vector use arrays to store data. The number of elements in the array is greater than that in the actual data storage to add and insert elements. They allow the element to be indexed by serial number directly, however, inserting elements involves memory operations such as array element movement, so index data is fast and data insertion is slow. Because vector uses the Synchronized Method (thread-safe), its performance is generally inferior to that of arraylist, the sorted list uses a two-way linked list for storage. Data indexed by serial number needs to be traversed in the forward or backward direction. However, when inserting data, you only need to record the items before and after this item, so the insertion speed is fast.
8. Design four threads. Two of them increase 1 to J each time, and the other two threads decrease 1 to J each time. Write the program.
The following programs use internal classes to implement threads, and do not consider the sequence when J is added or subtracted.
Public class threadtest1 {
Private Int J;
Public static void main (string ARGs []) {
Threadtest1 TT = new threadtest1 ();
INC 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 Inc implements 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. built-in JSP objects and methods.
Request request indicates the httpservletrequest object. It contains information about browser requests and provides several useful methods for obtaining cookie, header, and session data.

Response response indicates the httpservletresponse object, and provides several methods (such as cookies and header information) for setting the response to the browser)

The out object is an instance of javax. jsp. jspwriter. It provides several methods for sending output results to the browser.

Pagecontext indicates a javax. servlet. jsp. pagecontext object. It is used to facilitate access to various namespaces and servlet-Related Object APIs, and encapsulates common servlet-related functions.

Session session indicates a requested javax. servlet. http. httpsession object. Session can store user status information

Application applicaton indicates a javax. servle. servletcontext object. This helps you find information about the servlet engine and Servlet environment.

Config config indicates a javax. servlet. servletconfig object. This object is used to access the initialization parameters of the servlet instance.

Page page indicates a servlet instance generated from this page.
10. Write the communication between the client and the server using socket communication. The client must be able to echo the same data after sending the data.
See the socket communication example in the course.
11. Tell the servlet lifecycle and the difference between Servlet and CGI.
After the servlet is instantiated by the server, the container runs its init method, runs its service method when the request arrives, and the service method automatically dispatches the doxxx method (doget, dopost) corresponding to the request, etc, the destroy method is called when the server decides to destroy the instance.
The difference with CGI is that the servlet is in a server process and runs its service method in multi-thread mode. An instance can serve multiple requests, and its instance is generally not destroyed, CGI generates a new process for each request. After the service is completed, it is destroyed, so the efficiency is lower than that of servlet.
12. What technologies are EJB implemented based on? And the difference between sessionbean and entitybean, and the difference between statefulbean and statelessbean.

13. EJB includes (sessionbean, entitybean) telling about their lifecycle and how to manage transactions?

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

15 synchronization and Asynchronization have similarities and differences. Under what circumstances should they be used separately? Examples.

16 what are the app servers?

17 what are the collection classes you know? What are the main methods?

18 here is one for you: Driver A, data source name B, user name C, password D, database table T. Please use JDBC to retrieve all data in table t.

19. How are pages displayed on the JSP page?
Save the following parameters on the page:
Total number of rows: obtain the total number of rows based on SQL statements.
Number of lines per page: Set Value
Current page number: Request Parameters
The page calculates the number of rows in the first row of the current page based on the current page number and number of rows per page, locates the result set to this row, and retrieves the rows of the number of lines displayed on each page.

Database:

1. Differences between stored procedures and functions
A stored procedure is a collection of user-defined SQL statements involving tasks of a specific table or other objects. You can call the stored procedure. A function is usually a database-defined method, it receives parameters and returns some type of values, and does not involve specific user tables.
2. What is a transaction?
A transaction is a series of operations performed by a logical unit. A logical unit of work must have four attributes, called acid (atomicity, consistency, isolation, and persistence) attributes, only in this way can we become a transaction:
Atomicity
A transaction must be an atomic unit of work. modifications to its data must either be performed in all or not.
Consistency
When the transaction is completed, all data must be consistent. In related databases, all rules must be applied to transaction modifications to maintain the integrity of all data. At the end of the transaction, all internal data structures (such as B-tree indexes or two-way linked lists) must be correct.
Isolation
Modifications made by a concurrent firm must be isolated from those made by any other concurrent firm. The status of the data when the transaction is viewing the data is either the status before the transaction is modified or the status after the transaction is modified. The transaction does not view the data in the intermediate status. This is called serializability because it can reload the starting data and replays a series of transactions so that the State at the end of the data is the same as that of the original transaction execution.
Durability
After the transaction is completed, its impact on the system is permanent. This modification will be maintained even if a system failure occurs.

3. What is the role of a cursor? How do I know that the cursor has reached the end?
The cursor is used to locate the rows in the result set. by determining the global variable @ fetch_status, you can determine whether the result set is reached. Generally, this variable is not equal to 0, indicating that an error or the result set is reached.
4. triggers are divided into pre-trigger and post-trigger. There are differences between these two triggers. What is the difference between statement-level triggering and row-level triggering.
The trigger runs before the trigger event occurs, and the trigger runs after the trigger event. The trigger can obtain the new field values before the event.
A statement-Level Trigger can be executed before or after the statement is executed, and a row-Level Trigger is triggered once for each row affected by the trigger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.