1K

Senior Android Developer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Senior Android Developer was asked...January 31, 2017

Remove duplicate from contact list.

We can use a HashMap for it where name will be the key and phone number will be the value. If second time any name appears then its key will be already present in the map and it will be deleted. Less

Name can be same. A contact will be duplicated only if phone number is same. Need to use number as key. Less

Instead of map you can use set

Given a project, was required to refactor it using the MVP pattern an solving hard bugs presents.

Rewrote the entire project.

Rewrote the entire project+1

The key in these questions is to cover the fundamentals, and be ready for the back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Agoda or ex-Agoda Senior Android Developer experts on Prepfully? They give real-world practice and guidance, which is pretty helpful. prepfully.com/practice-interviews Less

Write algorithm to convert number for example 16 138 832 into "sixteen million one hundred thirty eight thousand eight hundred thirty two"

haven't checked leetcode, but how about this? firstly use (int)(Math.log10(number) + 1) to get the number of digits in the given number. (Note: you have to handle 0 differently) e.g 16138832 should return 8. Use this number of digits to get an idea of digit place's spelling (billion, million, thousand, hundred) Then for each digit (0~9) I'm thinking of using the previous answer's suggestion of HashMap to get the spelling. So I imagine there would be two HashMaps, one for getting the digit spelling (one, two, ... nine, ten, ... , nineteen), the other for the digit place spelling (billion, million, thousand, hundred, ... thirty, twenty) Less

Here is the answer. Sorry for the extra spaces :) private static String spellNumber(String number) { HashMap level1Num = new HashMap(); level1Num.put(1, " one "); level1Num.put(2, " two "); level1Num.put(3, " three "); level1Num.put(4, " four "); level1Num.put(5, " five "); level1Num.put(6, " six "); level1Num.put(7, " seven "); level1Num.put(8, " eight "); level1Num.put(9, " nine "); level1Num.put(10, " ten "); level1Num.put(11, " eleven "); level1Num.put(12, " twelve "); level1Num.put(13, " thirteen "); level1Num.put(14, " fourteen "); level1Num.put(15, " fifteen "); level1Num.put(16, " sixteen "); level1Num.put(17, " seventeen "); level1Num.put(18, " eighteen "); level1Num.put(19, " ninteen "); HashMap level2Num = new HashMap(); level2Num.put(2, " twenty "); level2Num.put(3, " thirty "); level2Num.put(4, " fourty "); level2Num.put(5, " fifty "); level2Num.put(6, " sixty "); level2Num.put(7, " seventy "); level2Num.put(8, " eighty "); level2Num.put(9, " ninty "); String output = ""; while (number.length() &gt; 0) { String block; if (number.length() % 3 == 0) { block = number.substring(0, 3); } else { block = number.substring(0, (number.length() % 3)); } if (block.length() &gt; 2) { output += level1Num.get(Integer.parseInt(block.substring(0, 1))) + " hundred "; number = number.replace(block.subSequence(0, 1), ""); block = block.replace(block.subSequence(0, 1), ""); } int block2 = Integer.parseInt(block); if (block2 = 7 &amp;&amp; number.length() = 4 &amp;&amp; number.length() &lt;= 6) { output += " thousand"; } number = number.replace(block, ""); } return output; } Less

It was hard to write under pressure. Basically, I was using HashMap. Key for integer, value for spelling. Solution you can find somewhere at leetcode Less

How to make a global error class for Retrofit errors?

I answered we can make a generic class for errors which can be used throughout the app. They wanted a specific name. They then answered that we can use GlobalErrorScope for it. It doesn't make sense. You can name it anything internally. Less

Create Kotlin Sealed class that can be used as enum for handling different status Less

How the viewpager is implemented?

When a fragment is loaded, the next one and the previous one are in cache.

Add in xml , create adapter , send fragments instance to adapter instance , the viewpager will show fragments by order Less

when working different threat than main threat which androi api do you use ?

Handler

It depends , you can use AsyncTask as well.

there will be two array like below, merge and sort them. arr1 = {1,5} arr2={3,6,_,_} result = 1,3,5,6

Assuming the array is sorted. class myCode { public static void main (String[] args) throws java.lang.Exception { int a[] = {1,3,5,7,9}; int b[] = {-1, 0,2,4,6,7,8,9,10}; int c[] = new int[a.length+b.length]; if (b &gt; a[a.length-1]) { // Merge array b to a in O(n) times } else { int i = 0; int j = 0; int k = 0; while (i &lt; a.length) { if (a[i] &lt;= b[j]) { c[k++] = a[i++]; } else if (b[j] &lt;= a[i]) { c[k++] = b[j++]; } else { c[k++] = a[i++]; c[k++] = b[j++]; } } while (j &lt; b.length) { c[k++] = b[j++]; } } for (int i = 0 ; i &lt; c.length; i++) { System.out.println(c[i]); } } } Less

static void mergeAndPrint(int[] one, int[] two) { int[] result = new int[one.length + two.length]; int oneIndex = 0, twoIndex = 0; for (int i = 0; i = one.length) { result[i] = two[twoIndex]; twoIndex++; } else if (twoIndex &gt;= two.length) { result[i] = one[oneIndex]; oneIndex++; } else { int o = one[oneIndex]; int t = two[twoIndex]; if (o &lt;= t) { result[i] = o; oneIndex++; } else { result[i] = t; twoIndex++; } } } System.out.println(Arrays.toString(result)); } Less

1. Android components 2. App lifecycle. 3. Design pattern

Nothing.

Activity Lifecycle Methods onCreate() Called when activity first created onRestart() Called after activity stopped, prior to restarting onStart() Called when activity is becoming visible to user onResume() Called when activity starts interacting with user onPause() Called when a previous activity is about to resume onStop() Called when activity no longer visible to user onDestroy() Final call received before activity is destroyed ----------------- Creational patterns: Builder (e.g. AlertDialog.Builder) Dependency Injection (e.g. Dagger 2) Singleton Structural patterns: Adapter (e.g. RecyclerView.Adapter) Facade (e.g. Retrofit) Behavioral patterns: Command (e.g. EventBus) Observer (e.g. RxAndroid) Model View Controller Model View ViewModel (similar to the MVC pattern above) Less

What is Dependency injection

Resuming... DI is a technique whereby one object supplies the dependencies of another object. Dagger 2 is the well know compile-time framework for dependency injection in Android. Less

DI is a technique whereby one object supplies the dependencies of another object. Dagger 2 is the well know compile-time framework for dependency injection in Android. Less