android面试之今日头条/字节跳动 android社招面试(附答案)

一面

  1. 自我介绍
  • 注意点:说有亮点的、跳槽缘由,从各个点尽力彰显本身优点、技术特长
  1. 手写代码:计算View树上全部view的数量,参数ViewGroup
  • 本质上就是数据结构多叉树递归层序遍历+Android View基本api调用
public int getCount(ViewGroup viewGroup){

        int count=viewGroup.getChildCount();

        //循环获取子View
        for(int i=0;i<count;i++){
            View child=viewGroup.getChildAt(i);
            if(child instanceof ViewGroup){
                //若是子View是ViewGroup,则用递归获取子View数量
                int childCount = getCount((ViewGroup)child);
                count+=childCount;
            }else {
                count++;
            }
        }
        
        return count;
    }
  1. Android相关
线程的阻塞状态(Blocked):阻塞状态是线程由于某种缘由放弃CPU使用权,暂时中止运行。直到线程进入就绪状态,才有机会转到运行状态。
主线程Looper从消息队列读取消息,当读完全部消息时,主线程阻塞。子线程往消息队列发送消息,而且往管道文件写数据,主线程即被唤醒,从管道文件读取数据,主线程被唤醒只是为了读取消息,当消息读取完毕,再次睡眠。所以loop的循环并不会对CPU性能有过多的消耗。
  1. 项目相关
  • 用MultiDex解决何事?其根本缘由在于?Dex如何优化?主Dex放哪些东西?主Dex和其余
    Dex调用、关联?Odex优化点在于什么?
  • 答案:MultiDex解决方法数65535的限制问题,即方法数不能超过65535个;方法id是short类型4个字节来存储的,因此数目范围应在0-2^32即0-65535;MultiDex工做原理分析和优化方案; 主dex中:应用启动就必须加载的类,有一个keep文件来控制;其余dex文件都是经过主dex加载进来的;odex优化点:预加载;
  • Dalvik和Art虚拟机区别?
  • 多渠道打包如何实现(Flavor、Dimension应用)?从母包生出渠道包实现方法?渠道标识替换原理?
  • Android打包哪些类型文件不能混淆?
a. 四大组件
  1. 架构

二面

  1. Glide缓存特色
  2. 问了擅长哪一个方向?回答UI动画,因此就问UI相关的
  1. 算法题
public static void main(String[] args){
        Counter counter=new Counter();
        new Thread(new PrintOdd(counter)).start();
        new Thread(new PrintEven(counter)).start();
    }

    static class PrintOdd implements Runnable {
        public Counter counter;

        public PrintOdd(Counter counter) {
            this.counter = counter;
        }

        @Override
        public void run() {
            while (counter.value<=100){
                synchronized (counter){
                    if(counter.odd){
                        System.out.println(Thread.currentThread().getName()+":"+counter.value);
                        counter.value++;
                        counter.odd=!counter.odd;
                        counter.notify();
                    }
                    try {
                        counter.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    static class PrintEven implements Runnable {
        public Counter counter;

        public PrintEven(Counter counter) {
            this.counter = counter;
        }

        @Override
        public void run() {
            while (counter.value<=100){
                synchronized (counter){
                    if(!counter.odd){
                        System.out.println(Thread.currentThread().getName()+":"+counter.value);
                        counter.value++;
                        counter.odd = !counter.odd;
                        counter.notify();
                    }
                    try {
                        counter.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    static class Counter{
        public int value = 1;
        public boolean odd = true;
    }
  1. 模块化、工程化架构思想

三面

  1. 设计个IM客户端以及数据库架构,相似微信,偏上层业务部分的会话、联系人、通知、
    公众号如何存、分几张表,架构每一层都是什么,互相怎么交互工做?

四面-HR

  1. 通常都会过

参考

  1. 面试字节跳动社招,我工资涨了60%,附带面经