面试ap公司试题

递归实现十进制转二进制
import java.util.Scanner;
public class DecToBin {
public static void main(String[] args) {
    int input;
    Scanner scan = new Scanner(System.in);
    System.out.print("Enter number to convert to binary: ");
    input = scan.nextInt();
    convert(input);
}
public static void convert(int num) {
    if (num>0) {
        convert(num/2);
        System.out.print(num%2 + " ");
    }
}
}

android如何做布局优化

尽量多使用RelativeLayout,不要使用绝对布局AbsoluteLayout;
将可复用的组件抽取出来并通过< include />标签使用;
使用< ViewStub />标签来加载一些不常用的布局;
使用< merge />标签减少布局的嵌套层次

http://blog.csdn.net/guolin_blog/article/details/43376527

MeasureSpec有哪几种模式。介绍下。

http://blog.csdn.net/lmj623565791/article/details/24252901

EXACTLY:一般是设置了明确的值或者是MATCH_PARENT
AT_MOST:表示子布局限制在一个最大值内,一般为WARP_CONTENT
UNSPECIFIED:表示子布局想要多大就多大,很少使用

最短路径问题D到A。并写出算法分析。(大学题)

http://www.cnblogs.com/skywang12345/p/3711516.html
这里写图片描述


IntentService的用法
一、IntentService简介 
IntentService是Service的子类,比普通的Service增加了额外的功能。先看Service本身存在两个问题:  

Service不会专门启动一条单独的进程,Service与它所在应用位于同一个进程中;  
Service也不是专门一条新线程,因此不应该在Service中直接处理耗时的任务;  
二、IntentService特征 

会创建独立的worker线程来处理所有的Intent请求;  
会创建独立的worker线程来处理onHandleIntent()方法实现的代码,无需处理多线程问题;  
所有请求处理完成后,IntentService会自动停止,无需调用stopSelf()方法停止Service;  
为Service的onBind()提供默认实现,返回null;  
为Service的onStartCommand提供默认实现,将请求Intent添加到队列中; 
IntentService不会阻塞UI线程,而普通Serveice会导致ANR异常
Intentservice若未执行完成上一次的任务,将不会新开一个线程,是等待之前的任务完成后,再执行新的任务,等任务完成后再次调用stopSelf

intent-filter的匹配原则

https://developer.android.com/guide/components/intents-filters.html

对于隐式意图,在定义Activity时,指定一个intent-filter,当一个隐式意图对象被一个意图过滤器进行匹配时,将有三个方面会被参考到:

动作(Action)

类别(Category )

数据(Data )

<activity android:name=".MainActivity"  android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.wpc.test" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/gif"/>
            </intent-filter>
</activity>

为什么不建议过度使用枚举类。

http://stackoverflow.com/questions/29183904/should-i-strictly-avoid-using-enums-on-android
http://stackoverflow.com/questions/4822877/why-doesnt-android-use-more-enums


Android中Thread、Handler、Looper、MessageQueue的原理分析

http://blog.csdn.net/bboyfeiyu/article/details/38555547


android sqlite批量插入数据速度解决方案(sqlite批处理)

http://stackoverflow.com/questions/3501516/android-sqlite-database-slow-insertion

db.beginTransaction();
for (entry : listOfEntries) {
    db.insert(entry);
}
db.setTransactionSuccessful();
db.endTransaction();

bitmap使用注意的问题。bitmap为什么要手动recycle。

https://github.com/android-cn/android-discuss/issues/82

手动调用Recycle的情况是:

你已经确定你不会再使用这张Bitmap了,这时候清空其引用不去释放,系统GC的时候会释放掉,但是这时候手动去释放会让你的应用程序内存不那么吃紧,而且如果你有很多Bitmap不去手动释放而等待系统GC的时候去释放,那你的应用程序在GC的时候会非常的卡顿,这样体验也不好。
如果你监听onTrimMemory回调,那么应该在系统内存比较低的时候,释放掉大部分可以动态生成的资源,比如图片Cache和Bitmap。这样可以保证你的应用程序在低内存的时候不会被杀掉,下一场启动也会快很多。

Tcp三次握手原理。

http://baike.baidu.com/item/%E4%B8%89%E6%AC%A1%E6%8F%A1%E6%89%8B


Android-Service系列之多线程断点续传下载

http://www.imooc.com/learn/376


activity的四种启动模式。

http://blog.csdn.net/mynameishuangshuai/article/details/51491074


混淆文件 proguard-rules.pro?

http://blog.csdn.net/zuiwuyuan/article/details/48552701
http://hanhailong.com/2015/12/28/Android%E8%BF%9B%E9%98%B6%E4%B9%8BProGuard%E4%BB%A3%E7%A0%81%E6%B7%B7%E6%B7%86/
- 为什么proguard配置中要加-keepattributes Signature?

#过滤泛型  出现类型转换错误时,启用这个
Gson uses generic type information stored in a class file when working with fields. Proguard removes such information by default, so configure it to keep all of it.

http://relex.me/keepattributes-signature/

  • 为什么proguard配置中要加keepattributes Annotation
    使用注解

Android JNI原理分析

http://gityuan.com/2016/05/28/android-jni/


Java 动态代理作用是什么?用UML图画出来

按照代理的创建时期,代理类可以分为两种:

  • 静态代理:由程序员创建或特定工具自动生成源代码,再对其编译。在程序运行前,代理类的.class文件就已经存在了。
  • 动态代理:在程序运行时,运用反射机制动态创建而成。

https://www.zhihu.com/question/20794107
这里写图片描述


如何终止一个子线程

http://stackoverflow.com/questions/10961714/how-to-properly-stop-the-thread-in-java
其实设置标志位false不会立刻终止thread,这是好恶心的。建议使用Interrupt。。

if (Thread.currentThread().isInterrupted()) {
  // cleanup and stop execution
  // for example a break in a loop
}
设计模式几大原则

http://www.uml.org.cn/sjms/201211023.asp

设计模式六大原则(1):单一职责原则

设计模式六大原则(2):里氏替换原则

设计模式六大原则(3):依赖倒置原则

设计模式六大原则(4):接口隔离原则

设计模式六大原则(5):迪米特法则

设计模式六大原则(6):开闭原则

java 组合和继承

http://www.hollischuang.com/archives/131
http://www.importnew.com/12907.html


依赖注入的使用。

https://github.com/android-cn/blog/tree/master/java/dependency-injection


如何写单元测试。

http://www.jianshu.com/p/03118c11c199

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值