In the Android development interview, what questions do you like to ask most during the interview?

"What high-quality Android interviews have you encountered?"

This is a hot topic I saw on Zhihu a few days ago. When I saw that I became interested, I tried to scroll down. I saw that the answers below were all sharing, telling my interview experience, interview feelings, and Thoughts and summary after the interview. It might as well be wonderful.

But seeing that the question time was 3 years ago, why is there still a heat wave after 3 years?

Thinking about this question, I read the Q&A in its entirety. I thought about the question time, and then I thought about the push time I received. I realized that it was approaching the "golden, nine, silver, and ten job-hopping golden periods", and most programmers were eager to try, so the question and answer three years ago once again set off a heat wave.

Consider that I have been in the Internet industry for three years, and I have interviewed no less than ten major factories in the past few years. There are also 3 offers, including Xiaomi, NetEase, and Sina. Now I am paddling fish in ByteDance, and I have a chance to be together! The average level of the offers I got is around 24K-27K (working for 1-2 years), I will use the opportunity of Q&A to do a wave of interview review.

1. Xiaomi (2019.4.17)

1. Introduce the project

I used to make a news app, which is equivalent to low imitation today's headlines!

basic skills:

  • Welcome page loading (3s, click to skip)-Activity related

  • User registration/login-SQLite application

  • Horizontal sliding list displays news categories-applications of TabLayout, ViewPager, FragmentPagerAdapter

  • Bottom menu bar switching-Fragment application

  • Home page (display news list)-ListView

  • Settings (log out of the application, log out, clear the cache)-Activity management, SharePreference

  • My (account security, news favorites)-SQLite

  • The news list pulls down and slides up to achieve refresh-custom ListView

  • Collect news one by one, delete news-SharePreference

  • Imitation UI interface-use of various controls

  • Click to view news details-WebView

  • User interface change avatar function-Android runtime permissions, multimedia, Content Provide

2. Briefly talk about the Activity life cycle?

The figure below is the state transition diagram of Activity (note that in the figure, what is executed in the box is the process of state transition, not state. As mentioned above, there are only three states: RUNNING / PAUSED / STOPPED.)

3. Briefly describe the RecyclerView caching mechanism?

RecyclerView can be said to have replaced listview in Android applications. Its flexibility, assembly-style settings, and multi-caching mechanism can adapt to the various needs of multiple lists in Android development.

For RecyclerView's caching mechanism, I have always wanted to think about it a little bit. To put it simply, RecyclerView has two more levels of cache support compared to the listview cache mechanism. Listview is a two-level cache, and RecyclerView is a four-level cache (of course, in most cases) Is a three-level cache).

4. In a listview, each item has an animated (gif) view, and the animation (gif) plays when I click the button in the item. When you slide the listview when an animation is playing, occasionally an item misalignment event will occur. what is the reason?

This is a problem of item reuse, because the image is misplaced due to asynchronous loading

5. When the Activity has multiple Handlers, will the Message messages be messed up? How to distinguish which Handler handles the current message?

There will be no confusion, which Handler sends messages will also be handled by this handler at that time. When sending a message, the target is bound. This target is the Handler itself. When the handler needs to call dispatchMessage(msg) to process the message, this Handler is the handler bound when sending the message.

No matter which method is used to send the message, enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) will eventually be called to send the message

private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
        msg.target = this;
        if (mAsynchronous) {
            msg.setAsynchronous(true);
        }
        return queue.enqueueMessage(msg, uptimeMillis);
    }

This here is the current handler. When looking at the need for Handler to process messages, which handler is taken, the main source code is posted below.

public static void loop() {
  ......
        for (;;) {
            Message msg = queue.next(); // might block
            if (msg == null) {
                // No message indicates that the message queue is quitting.
                return;
            }

            // This must be in a local variable, in case a UI event sets the logger
         ......
            if (traceTag != 0 && Trace.isTagEnabled(traceTag)) {
                Trace.traceBegin(traceTag, msg.target.getTraceName(msg));
            }

            final long dispatchStart = needStartTime ? SystemClock.uptimeMillis() : 0;
            final long dispatchEnd;
            try {
                msg.target.dispatchMessage(msg);
                dispatchEnd = needEndTime ? SystemClock.uptimeMillis() : 0;
            } finally {
                if (traceTag != 0) {
                    Trace.traceEnd(traceTag);
                }
            }
           ......

            msg.recycleUnchecked();
        }
    }

This is part of the code when the message is looped. The message processing code is msg.target.dispatchMessage(msg);, where the target is the handler that sends the message at that time.

2. NetEase (Interview on May 2019)

1. Introduce the project

I just said, not much introduction

2. Tell me about your understanding of strong, weak, and soft references in Java

Strong reference: This type of reference is the type of reference that we usually use frequently. The JVM defaults to this type of reference, for example, A a = new A(), which is a strong reference;

In this type, when the memory space is insufficient, the JVM would rather OOM, causing the program to abort and exit, and would not reclaim it arbitrarily. Only when the object is not referenced, will the JVM reclaim it.

Soft reference: We can use this kind of reference like this, SoftReference sr = new SoftReference(new A()); You can use sr.get() to get this object, this kind of reference type object, if the JVM memory is enough, it will not He will be recycled; if the JVM memory is insufficient, these objects will be recycled. This type of reference is suitable for use as a cache.

Weak reference: This kind of reference can be used for this purpose, WeakReference wr = new WeakReference(new A()); and then use wr.get() to get this object; this kind of reference type object has more properties than soft referenced objects. In a shorter life cycle, when the garbage collector scans the memory area of ​​the JVM, when it encounters objects of this type of reference, it will reclaim these objects regardless of whether the current memory is sufficient.

3. What is a deadlock? What are the necessary conditions? How to avoid it?

  • Deadlock refers to a situation in which multiple processes are waiting for the resources occupied by other parties in a loop and remain deadlocked indefinitely. When two or more processes simultaneously request the use of multiple mutually exclusive resources, a deadlock may occur.

  • Mutually exclusive conditions: that is, only one process can use resources at a time, and other processes cannot access resources that have been allocated to other processes

  • Occupy and wait: When a process waits for another process to release a resource, it is known to occupy the resource

  • Non-preemption: other processes cannot forcibly occupy the resources that have been allocated to the process

  • Circular waiting: There is a closed chain, and the processes in the chain occupy at least one resource required by the next process in the chain

Deadlock avoidance:

  • Prevention of mutual exclusion: impossible to prohibit

  • Prevent possession and wait: Let the process apply for all resources at once.

  • Prevention of non-preemption: (1) When the resource-occupying process further applies for resources, it refuses and then forcibly releases the currently occupied resources. You can apply again if necessary. (2) When a process requests a resource occupied by another process, the operating system can preempt the process occupying the resource. Request the release of resources. The second solution is only if any two processes have different priorities.

  • Prevent loop waiting: define a linear sequence of resource access

4. The difference between TCP and UDP

  1. Based on connection and no connection.

  2. TCP requires more system resources, while UDP is less.

  3. The UDP program structure is relatively simple.

  4. Streaming mode (TCP) and datagram mode (UDP).

  5. TCP guarantees the correctness of the data, and UDP may lose packets.

5. Algorithm question : Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine whether s can be split into one or more words appearing in the dictionary by spaces.

Answer analysis: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine whether s can be split into one or more words appearing in the dictionary by spaces. Answer analysis

Android

1. What methods need to be rewritten for custom View?

(Combined with actual needs, rewrite onTouchEvent if you need to slide, and rewrite onMeasure, onLayout if you need to control your own layout)

2. How to optimize the layout?

Answer analysis: layout optimization_qq_39477770的博客-CSDN博客

3. Handler message mechanism

Answer analysis: The most complete interpretation of the principle of the Android Handler message mechanism (continuing to add)

4. Talk about your understanding of UI optimization

Answer analysis: UI optimization wfeii's blog -CSDN blog ui optimization

3. Sina (2019.12.21)

1. Introduce the project

I just said, not much introduction

2. Have you ever learned about plug-inization? What is the difference between plug-in and componentization?

Answer analysis: the difference between modularization, componentization and plug-inization

3. When to use the Context of Application and when to use the Context of Activity

Answer analysis: When to use Application Context, when to use Activity Context_lulinhua1010

4. Do I have to update the UI in the main thread? Can it be updated in a child thread?

Answer analysis: Do I have to update the UI in the main thread? Can it be updated in a child thread?

5. How is Kotlin compatible with Java?

Answer analysis: How is kotlin compatible with Java? Answer analysis

After so many reviews, in fact, careful friends can find that the interviews of big companies still value the basics of Java and Android. Therefore, it is necessary to sort out a wave of knowledge before the interview.

1. Java basic interview inspection points

  • JVM workflow

  • Runtime Data Area

  • Class loader

  • Garbage collection GC

  • String、StringBuffer、StringBuilder

  • interface

  • HashMap

  • Singleton mode

  • Thread attributes, status, status control

  • synchronized

  • volatile

2. Android basic interview inspection points

  • Activity: life cycle, startup mode, startup process

  • Fragment: characteristics, life cycle, communication with Activity

  • Service: startup process, binding process, life cycle, enable foreground service (registration process), BroadcastReceiver, ContentProvider, data storage

  • View: Basic flow of MeasureSpec, MotionEvent, VelocityTracker, GestureDetector, View sliding, Scroller, event distribution, custom View, Draw

  • Process: the life cycle of the process, multi-process, OOM_ADJ

  • Parcelable interface: Parcelable and Serializable comparison

  • IPC: IPC method, Binder, AIDL communication, Messenger

  • Bitmap: common operations: crop, zoom, rotate, move, Bitmap and drawabl, conversion, save and release, image compression, BitmapFactory, Bitmap creation process, Option class

  • Screen adaptation: (Toutiao, Douyin) adaptation scheme, Liu Haiping adaptation

  • Message mechanism: Handler mechanism, working principle (ThreadLocal, MessageQueue, Looper, Handler)

  • Thread asynchronous: AsyncTask, HandlerThread, IntentService, thread pool, RecyclerView optimization

  • Webview: WebView, WebSetings, WebViewClient, WebChromeClient, Webview loading optimization, memory leak

3. Android extended knowledge test points

  • ART: AOT compilation, garbage collection priority, development debugging and tuning, GC

  • Apk package body optimization: Apk structure composition, overall optimization, resource optimization, code optimization, .arsc file optimization, lib directory optimization

  • Proguard: public templates, custom obfuscation principles

  • Architecture patterns: MVC, MVP, MVVM

  • Jetpack: Architecture pattern

  • NDK development: JNI basics (data types, String string function operations, the usual methods of accessing Java), basic development principles, Cmake to build NDK projects, common Android NDK native APIs

4. Computer network interview inspection site

  • Http related: request message and response, message caching mechanism, HttpsHttp 2.0

  • TCP/IP: Three-way handshake, four waved hands, the difference between TCP and UDP

  • Socket: usage example

  • Class loader: Parent delegation mode, DexPathList

Because the document has 1200 pages, the content is too much. There are also some design patterns, source code, and algorithm interview questions, so I won't introduce them one by one.

Recently, gold and three silver four want to quit interview friends , can be traced to learn this knowledge point summary of the interview Android version of the PDF, which I have to GitHub in; in addition to manufacturers face questions summary + Advanced Android Advanced thinking Figure + Android source code notes + advanced learning video can also be viewed in my GitHub project address: https://github.com/733gh/Android-T3 .

Guess you like

Origin blog.csdn.net/u012165769/article/details/114142822