Overview
Finding a job is difficult. In order to better deal with the interview, I have collected and sorted out some interview questions so that I can review it at any time.
1. Please talk about the architecture of the Android system.
Answer: The Android system adopts a hierarchical architecture, from the high to the low level, namely the application layer, the application framework layer, the system runtime library layer and the linux core layer.
2. Talk about the five commonly used layouts by Android.
Answer: In Android, there are five layout methods, namely: FrameLayout, LinearLayout, AbsoluteLayout, RelativeLayout, and TableLayout.
- (1) FrameLayout Frame layout, all elements placed in it are placed in the upper leftmost area, and it is impossible to specify an exact position for these elements. The next child element will overlap the previous child element, which is suitable for browsing a single image.
- (2) LinearLayout is the most commonly used layout method in applications. It mainly provides models of horizontal or vertical arrangement of controls. Each subcomponent is positioned vertically or horizontally. (The default is vertical)
- (3) AbsoluteLayout Absolute positioning layout, which uses the coordinate axis to locate the component. The upper left corner is the (0, 0) point, increments to the right x-axis and increments to the lower Y-axis. The component positioning properties are android:layout_x and android:layout_y to determine the coordinates.
- (4) RelativeLayout: The relative layout of RelativeLayout, determine the location of the next component based on another component or the top-level parent component. Similar to the one in CSS.
- (5) TableLayout table layout, similar to Table in Html. Use TableRow to layout, where TableRow represents a row, and each view component of TableRow represents a cell.
3. Talk about Android data storage methods.
Answer: Android provides 5 ways to store data:
- (1) Use SharedPreferences to store data; it is a mechanism provided by Android to store some simple configuration information, and uses XML format to store data into the device. It can only be used within the same package, not between different packages.
- (2) File storage data; file storage method is a more commonly used method. The method of reading/writing files in Android is exactly the same as that of programs that implement I/O in Java. It provides openFileInput() and openFileOutput() methods to read files on the device.
- (3) SQLite database stores data; SQLite is a standard database brought by Android. It supports SQL statements and is a lightweight embedded database.
- (4) Use ContentProvider to store data; it is mainly used for data exchange between applications, so that other applications can save or read various data types of this Content Provider.
- (5) Data is stored in the network; upload (storage) and download (get) the data information we store in the network through the storage space provided to us on the network.
What are the differences between Activity, Intent, Content Provider, and Service?
answer:
- Activity: Activity is the most basic android application component. An activity is a separate screen, each activity is implemented as a separate class and inherited from the activity base class.
- Intent: Intent, describe what the application wants to do. The most important part is the data corresponding to the action and the action.
- Content Provider: Content Provider, android applications are able to save their data to files, SQLite databases, or even any valid device. Content providers are available when you want to share your app data with other apps.
- Service: Service, a program with a long life cycle without a user interface.
, surfaceView, GLSurfaceView What is the difference?
answer:
- The view is the most basic and must update the screen in the main UI thread, which is slower.
- SurfaceView is a subclass of view, similar to using a double-daily mechanism, which updates the screen in a new thread, so the refresh interface speed is faster than the view.
- GLSurfaceView is a subclass of SurfaceView, dedicated to opengl
What are the functions? What are the common Adapters?
answer:
Adapter is an adapter interface that connects backend data and frontend display. Common Adapters include ArrayAdapter, BaseAdapter, CursorAdapter, HeaderViewListAdapter, ListAdapter, ResourceCursorAdapter, SimpleAdapter, SimpleCursorAdapter, SpinnerAdapter, WrapperListAdapter, etc.
What information is mainly included in the file?
answer:
- manifest: root node, describes all contents in the package.
- uses-permission: Request the security permissions required for your package to function properly.
- permission: Declares a security permission to limit which programs can be used to components and functions in your package.
- instrumentation: Declares the code used to test this package or other package directive components.
- application: contains the root node declared by the application level component in the package.
- activity: Activity is the main tool used to interact with users.
- receiver: IntentReceiver can make the application to obtain data changes or operations that occur even if it is not currently running.
- service: Service is a component that can run at any time in the background.
- provider: ContentProvider is a component used to manage persistent data and publish it to other applications.
8. Please write a piece of code (SAX, DOM, or pull) to parse the XML document.
Answer: The following is the XML file to be parsed:
Zhang San
22 Li Si
23 Define a javaBean named Person to store the parsed XML content
public class Person { private Integer id; private String name; private Short age; public Integer getId() { return id; } public void setId(Integer id) { = id; } public String getName() { return name; } public void setName(String name) { = name; } public Short getAge() { return age; } public void setAge(Short age) { = age; } } (1)useSAXReadXMLdocument;It uses event-driven,There is no need to parse the complete document,Fast speed and takes up less memory。Need forSAXProvide implementationContentHandlerInterface class。 import ; import ; import ; import ; import ; import ; public class PersonDefaultHandler extends DefaultHandler { private List persons; private Person person ; //Record the current personprivate String perTag; //Record the name of the previous tag/** * Rewrite the start document method of the parent class. For initialization */ @Override public void startDocument() throws SAXException { persons = new ArrayList(); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if(“person”.equals(localName)){ Integer id = new Integer((0)); //Get idperson = new Person(); (id); } perTag = localName; } /**parameter: * ch The entire XML string * start The index position of the node value in the entire XML string * length The length of the node value */ @Override public void characters(char[] ch, int start, int length) throws SAXException { if(perTag!=null){ String data = new String(ch,start,length); if(“name”.equals(perTag)){ (data); }else if(“age”.equals(perTag)){ (new Short(data)); } } } @Override public void endElement(String uri, String localName, String qName) throws SAXException { if(“person”.equals(localName)){ (person); person = null; } perTag = null; } public List getPersons() { return persons; } } import ; import ; import ; import ; import ; public class SAXPerson{ public static List getPerson() throws Exception{ //Get file through class loaderInputStream inStream = ().getResourceAsStream(“”); SAXParserFactory factory = (); SAXParser saxParser = (); PersonDefaultHandler handler = new PersonDefaultHandler(); (inStream, handler); (); return (); } } (2)DOMAnalysisXMLdocument时,Will beXMLdocument的所有内容Read到内存中,然后允许您useDOM APITraversalXMLTree、Search the required data。 import ; import ; import ; import ; import ; import org.; import org.; import org.; import org.; import ; public class DOMPerson { public static List getPerson() throws Exception{ List pers = new ArrayList(); InputStream inStream = ().getResourceAsStream(“”); DocumentBuilderFactory factory =(); DocumentBuilder builder = (); Document dom = (inStream); Element root = (); NodeList persons = (“person”); for(int i=0;i<();i++){ Element personNode =(Element)(i); Person person = new Person(); (new Integer(("id"))); NodeList childNodes = (); for(int j=0;j<();j++){ Node childNode = (j); if(()==Node.ELEMENT_NODE){ Element element = (Element)childNode; if("name".equals(())){ (new String(().getNodeValue())); }else if("age".equals(())){ (new Short(().getNodeValue())); } } } (person); } (); return pers; } } (3)usePullAnalysis器ReadXMLdocument import ; import ; import ; import ; import ; import .; import .; import ; import ; import ; public class PullPerson { public static void save(List persons) throws Exception{ XmlSerializer serializer = (); File file = new File((),””); FileOutputStream outStream = new FileOutputStream(file); (outStream,”UTF-8″); (“UTF-8″, true); (“”, “persons”); for(Person person:persons){ (“”, “person”); //person (“”, “id”, “”+()); (“”, “name”); //name (()); (“”, “name”); //name (“”, “age”); //age (().toString()); (“”, “age”);//age (“”, “person”); //person } (“”, “persons”); (); (); } public static List getPersons() throws Exception{ List persons = null; Person person = null; XmlPullParser parser= (); InputStream inStream = ().getResourceAsStream(“”); (inStream, “UTF-8″); int eventType = (); // Trigger the first eventwhile(eventType!=XmlPullParser.END_DOCUMENT){ switch(eventType){ case XmlPullParser.START_DOCUMENT: persons = new ArrayList(); break; case XmlPullParser.START_TAG: //Start element eventif(“person”.equals(())){ person = new Person(); (new Integer((0))); }else if(person!=null){ if(“name”.equals(())){ (()); }else if(“age”.equals(())){ (new Short(())); } } break; case XmlPullParser.END_TAG: //End element eventif(“person”.equals(())){ (person); person = null; } break; default: break; } eventType = (); } return persons; } } Choose any of the above three methods。
9. Describe Android digital signature based on your own understanding.
answer:
- (1) All applications must have digital certificates. Android system will not install an application without digital certificates.
- (2) The digital certificate used by the Android package can be self-signed and does not require an authoritative digital certificate institution signature authentication
- (3) If you want to officially release an Android, you must use a digital certificate generated by the appropriate private key to sign the program, and cannot use the debug certificate generated by the adt plug-in or ant tool to publish it.
- (4) Digital certificates have validity periods, and Android will only check the validity period of the certificate when the application is installed. If the program is already installed in the system, even if the certificate expires, it will not affect the normal function of the program.
10. The head structure of a single linked list is known, write a function to reverse the linked list.
Answer: As shown below
public class Node { private Integer count; private Node nextNode; public Node(){ } public Node(int count){ = new Integer(count); } public Integer getCount() { return count; } public void setCount(Integer count) { = count; } public Node getNextNode() { return nextNode; } public void setNextNode(Node nextNode) { = nextNode; } } public class ReverseSingleLink { public static Node revSingleLink(Node head){ if(head == null){ //The linked list is empty and cannot be reversedreturn head; } if(()==null){ //If there is only one node, of course, the same one will be the same when it comes back.return head; } Node rhead = revSingleLink(()); ().setNextNode(head); (null); return rhead; } public static void main(String[] args){ Node head = new Node(0); Node temp1 = null,temp2 = null; for(int i=1;i<100;i++){ temp1 = new Node(i); if(i==1){ (temp1); }else{ (temp1); } temp2 = temp1; } head = revSingleLink(head); while(head!=null){ head = (); } } }
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for your study or work. Thank you for your support. If you want to know more about it, please see the relevant links below