1. Value types, reference types?
Basic data types are value types: Byte,short,int,long,float,double,char,boolean
Other types are reference types.
Reference types in the incoming method, the modification of a reference type variable inside a method alters the contents of the reference type.
The value type pass parameter is copy.
2. Garbage collection?
GC Mechanism:
Android based on the components running in the process and their status specifies the default five recycle priority:
Importance_foreground:
Importance_visible:
Importance_service:
Importance_background:
Importance_empty:
Prevent memory overflow 1. Explicitly call System.GC ();
2. Retrieve the memory after the image processing is complete. Please make a memory recovery after calling bitmap for picture processing. Bitmap.recycle (); This frees the memory that was just used for the image.
3. Specify size when image processing
To prevent context memory leaks:
1). Do not refer to the context for a long time
2). Use ApplicationContext as much as possible
3). If you do not control the lifecycle, try to avoid using static variables in the activity.
4). Garbage collection is not necessarily timely, please cursor.close () in Ondestory in time.
3. Common design Patterns?
Adapter mode: Adapter for ListView or GridView.
Builder mode: Alertdialog.builder
Command mode: Handler.post after Handler.handlemessage
Enjoy meta mode: Message.obtainmessage to avoid the frequent creation and destruction of a large number of message objects by reusing the message object
Iterator mode: If you can get a enumeration through the Hashtable.elements method, and then access the data in Hashtable through this enumeration, instead of worrying about how the data is stored in Hashtable
Memo mode: The Onsaveinstancestate and onrestoreinstancestate of activity is to store the state of activity through the serialized data structure of the bundle, and as for the data structure stored in it, These two methods do not care
Observer Pattern: We can register with Baseadater, unregister a baseadapter.registerdatasetobserver and Baseadapter.unregisterdatasetobserver two method Datasetobserver. In this process, DATASETOBSERVER is an observer, and once it discovers that baseadapter internal data has variables, it Callback methods Datasetobserver.onchanged and datasetobserver.oninvalidated to notify the Datasetobserver implementation class. Event notifications are also observer patterns.
Prototype mode: For example, we need a bitmap of several different formats: argb_8888, rgb_565, argb_4444, alapha_8, etc. Then we can first create a argb_8888 Bitmap as a prototype, based on it, by calling Bitmap.copy (Config) to create several other formats of Bitmap. Another example is that all objects in Java have a method named Clone, which is synonymous with the prototype pattern.
Proxy mode: Similar to the delegate delegate mode for iOS development, all aidl are examples of a proxy pattern. Assuming that an activity a goes to bind a service s, each method in a call to S is actually brokered by the system's binder mechanism, and then calls the corresponding method in S. The binder mechanism acts as an agent.
State mode: The View.onvisibilitychanged method provides the implementation of a state pattern that allows actions in the Onvisibilitychanged method to be raised when the View's visibility changes.
Policy mode: Java.util.List is defined as an add, delete, change (set), check (INDEXOF) strategy, as for the implementation of this strategy ArrayList, LinkedList and other classes, A different algorithm is used only when the implementation is specific. But because of their strategy, regardless of the speed of the case, the use of the full can be replaced with each other.
Mediator mode: When an operation of an object requires the M method of invoking N objects to complete, the invocation process is encapsulated and becomes a mediator
Example: the implementation logic of the Resource.getdrawable method is this: Create a cache to hold all the loaded, if the getdrawable in the ID that corresponds to the drawable has not been loaded before, It will either invoke the XML parser generated according to the resource type corresponding to the ID, or create the drawable by reading the picture resource file in the package.
and resource.getdrawable the role of a mediator by encapsulating operations involving multiple objects and multiple logic into a single method.
Abstract Factory mode: The use of DAO and service.
4.MVC Development Model Understanding:
MVC----Model,view,control.
Model---control----view:
When the view changes, such as the ListView deletes a row, it notifies control that the control is manipulating the model's data changes.
Vice versa. MVC separates the display part from the part of the data so that it can be modified or replaced in part without affecting the data.
A common example: Arrayapdator corresponds to a ListView and data source.
Android interview (3)---basic questions