Java Interview Summary

Source: Internet
Author: User

    • What is the difference between sleep () and wait ()?
    1. Sleep is a method of the thread class, and wait is a method in the object class
    2. Sleep () does not release the sync lock, and wait () releases the sync lock
    3. After calling the wait () method, another thread is required to execute notify/notifyall to regain CPU execution time
    • Two ways to implement threading?

    1. Inherit the Java.lang.Thread and rewrite its run () method
    2. Implement the Java.lang.Runnable interface to implement its run () method
    • The difference between HashMap and Hashtable in Java
    1. HashMap allows null key-value pairs, while Hashtable does not allow
    2. HashMap non-synchronous, HashTable synchronization, HashMap efficiency >hashtable
    • The difference between String, StringBuilder, and StringBuffer
    1. The string object is immutable, and the other two mutable
    2. The object in string is immutable, is thread-safe, StringBuilder does not have a synchronous lock on a method, is not thread-safe, and StringBuffer adds a synchronous lock to a method, thread-safe
    • What is the difference between List, Map, and set?
    1. Set is the simplest kind of collection. The objects in the collection are not sorted in a particular way, and there are no duplicate objects. The set interface mainly implements two implementation classes:
      • The Hashset:hashset class accesses the objects in the collection according to the hashing algorithm, and the access speed is relatively fast.
      • The Treeset:treeset class implements the SortedSet interface and is able to sort the objects in the collection
    2. A list is characterized by its elements being stored in a linear fashion, in which duplicate objects can be stored in the collection
      • ArrayList (): Represents the length can be changed by the group. Elements can be randomly accessed, and it is slow to insert and delete elements into ArrayList ().
      • LinkedList (): A linked list data structure is used in the implementation. Fast insertion and deletion, and slow access times.
    3. Map is a collection of key object and value object mappings, each of which contains a pair of key objects and value objects
    • Name the storage performance and features of ArrayList, vectors, and linklist?
    1. ArrayList and vectors their underlying implementations are all the same, using arrays to store data, which is larger than the actual stored data in order to add and insert elements, both of which allow the element to be indexed directly by ordinal, but the insertion element involves memory operations such as array element movement, So indexing data is fast and inserting data is slow.
    2. The method in the vector is a thread-safe container because of the addition of the synchronized modifier, but the performance is less ArrayList
    3. LinkedList uses a two-way linked list for storage, index data by ordinal need forward or backward traversal, but insert data only need to record the item's front and rear items, so the insertion speed is faster
    • Brief introduction to Java garbage collection mechanism?

??????

    • Describe the main differences between PreparedStatement and statement in JDBC?
    1. Statement generates an execution plan for an SQL statement, and executes the plan multiple times if there are multiple SQL statements
    2. PreparedStatement is precompiled, used to reuse the execution plan using binding variables, by set different data only need to generate an execution plan, you can reuse
    • Brief description of how struts works
    1. STRUTS2 is a Web application framework that implements the MVC (Model-view-controller) design pattern
    2. The entire life cycle of the STRUTS2 begins with request requests from the client and then executes the corresponding filter through the servlet container
    3. Filterdispatcher is called, it determines which action will be executed by finding Actionmapper
    4. If you find an executable action,filterdispatcher in Actionmapper, delegate control to Actionproxy
    5. Actionproxy reads the struts.xml configuration file, Actionproxy creates a actioninvocation instance and gives control to the Actioninvocation instance
    6. Actioninvocation (which is in command-line design mode) Instances call interceptors one after the other and invoke the corresponding action
    7. Once the action has returned, Actioninvocation looks for the corresponding action in Struts.xml to return the result
    8. The interceptor then executes in reverse order and responds back to the filter. The result is then returned to the servlet container and sent to the window end.
    • Describe the life cycle of a servlet? The life cycle of a JSP?
    1. A servlet is run in a servlet container and its lifecycle is managed by the container. The life cycle of the servlet is represented by the Init (), service (), and Destory () methods in the Java.servlet.Servlet interface. The servlet's life cycle has four phases: load and instantiate, initialize, request processing, destroy
    2. The JSP page must be converted to a servlet to service the request, so the bottom of the JSP is completely servlet. It seems that the life cycle of the JSP consists of six phases: conversion, compilation, loading and instantiation, initialization, request processing (_jspservice () call), destroying

Java Interview Summary

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.