the difference between 1.Collection and collections .
Collection is the parent interface of the collection class, which inherits from the main interface of his Set and the List.
Collections is a helper class for a collection class that provides a series of static methods for searching, sorting, threading, and so on for various collections.
the difference between 2.HashMap and Hashtable .
HashMapis aHashtableLightweight implementations (non-thread-safe implementations), they all completed theMapinterface,HashMap isNon-threading security, which may be more efficient thanHashtable. access on multiple threads Hashtable , you do not need to implement synchronization for its methods, and HashMap You must provide external synchronization for it.
HashMap allow the NULL as a entry of the Key or value , while Hashtable not allowed.
HashMapputHashtableof thecontainsThe method is removed and changed intoContainsvalueand theContainsKey. Becausecontainsmethod is easy to cause misunderstanding. Hashtableinherit fromDictionaryclass, andHashMapis aJava1.2introduced byMap Interfaceone of the implementations.
Hashtable and the HashMap Use of Hash/rehash algorithms are probably the same, so there is no big difference in performance.
3. What is the difference between sleep () and wait () ?
Sleepis a thread class (Thread), which causes this thread to pause execution for the specified time, giving the execution opportunity to other threads, but the monitoring state remains and is automatically restored when it is. CalledSleepobject locks are not freed.
waitis aObjectMethod of the class that is called on this object .waitmethod causes the thread to discard the object lock and wait for the lock pool to wait for the object to be sent only for this objectNotifymethod (orNotifyallonly after this thread enters the object lock pool is ready to get the object lock into the running state.
4.shorts1 = 1; s1 = s1 + 1; What's wrong? ? short S1 = 1; s1 + = 1; What's wrong? ?
Short s1 = 1; s1 = s1 + 1; (s1+1 operation result is int type, need cast type) Short s1 = 1; s1 + = 1; (can be compiled correctly)
5. How much is Math.Round (11.5)? Math.Round ( -11.5) how much ?
Math.Round (11.5) ==12
Math.Round (-11.5) ==-11
The round method returns a long integer closest to the parameter, and the parameter is added to the floor .
1. Arraylist,vector, LinkedList storage performance and featuresboth ArrayList and vectors use 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 the index data is fast and the insertion data is slow, Vector due to the use of the Synchroni Zed method (thread safety), usually the performance of the ArrayList poor, and LinkedList using a doubly linked list for storage, index data by ordinal need forward or back traversal, However, when inserting data, you only need to record the item's front and rear items, so the insertion speed is faster.
the difference between 2.Collection and collectionsCollection is the ancestor interface of the collection class, and the main interface for inheriting it is set and List. Collections is a helper class for a collection class that provides a series of static methods for searching, sorting, threading, and so on for various collections.
the difference between 3.HashMap and HashtableHashMap is a lightweight implementation of Hashtable (non-thread-safe implementation), they all complete the Map interface, the main difference is that the HASHMAP allows null (NULL) key value (key), because of non-thread security, efficiency may be higher than Hashtable. HASHMAP allows NULL to be used as a entry key or value, and Hashtable is not allowed. HashMap Hashtable contains method removed, changed to Containsvalue and ContainsKey. Because the contains method is easy to cause misunderstanding. Hashtable inherits from the Dictionary class, and HashMap is an implementation of the Map interface introduced by Java1.2. The biggest difference is that the Hashtable method is Synchronize, and HashMap is not, when multiple threads access Hashtable, they do not need to synchronize their methods, and HASHMAP must provide external synchronization. the Hash/rehash algorithms used by Hashtable and HashMap are probably the same, so there is no big difference in performance.
What is the difference between 4.sleep () and wait ()Sleep is a threading class (thread) method that causes this thread to pause execution for a specified time, giving the execution opportunity to other threads, but the monitoring state remains and is automatically restored when it is finished. Calling sleep does not release the object lock. Wait is a method of the object class that calls the wait method on this object to cause the thread to discard the object lock, to wait for the lock pool to wait for the object, and only to emit the Notify method for this object (or Notifyall) After this thread enters the object lock pool is ready to get an object lock into the running state.
the difference between 5.Overload and Overridecan the Overloaded method change the type of the return value? The overridden overriding and overloaded overloading of a method are different manifestations of Java polymorphism. Overriding overriding is a representation of polymorphism between a parent class and a subclass, and overloading overloading is a representation of polymorphism in a class. If you define a method in a subclass that has the same name and arguments as its parent class, we say that the method is overridden (overriding). When an object of a subclass uses this method, the definition in the subclass is called, and for it the definition in the parent class is "masked". If more than one method with the same name is defined in a class, they either have a different number of arguments or have different parameter types, which is called a method overload (overloading). The Overloaded method is to change the type of the return value.
6. What are the similarities and differences between synchronous and asynchronous, and under what circumstances are they used separately? if the data will be shared between threads. For example, the data being written may be read by another thread later, or the data being read may have been written by another thread, then the data is shared and must be accessed synchronously. When an application calls a method that takes a long time to execute on an object and does not want the program to wait for the method to be returned, it should use asynchronous programming, which is often more efficient in many cases with asynchronous approaches.
JAVA (Basic) Android face question (iii)