Not another Interviews’ article: Android & Java Questions

[Previous Chapter — Think it through | Next Chapter — Kotlin Questions]

As before, let’s start with the “why?”. Why would I share a lot of the questions I normally use during an interview?

The answer is really simple. First of all, because when I started interviewing and being interviewed I wish I had something like this. I believe you are wondering if this doesn’t defeat the purpose of the interview, by enabling the person to study the questions. Well, I don’t believe so, for several reasons:

  1. Again using Facebook’s interview as a good example: their instructions received via email, before the interview, pointed to several sites that have lists of questions they ask. There isn’t an “official” one but, the truth is, a lot of the questions that I was asked were, at least, similar. Did it help me? Yes, because it made me understand what type of questions they would ask me. Did this alone help me pass? Not by a long shot. Really. Not by long long shot. Below you will see that I have added quite a few of the questions I normally ask, but not the answers. Well that’s not (just) because I was lazy, it’s really because it’s made for you to search and read about it. I don’t want to give you a small answer that you can just memorize and spit out to me… guess what, I want you to learn in the process!
  2. If you are really learning by using this, it will indeed help you in the interview, but that’s not the point, the whole point is… you’re learning and improving! You now know more, awesome!
  3. Even if you can memorize and spit out stuff.. I will find and I will kill you. Just kidding, but I will definitely ask you to explain and apply each concept that you are spitting out until you confess you’re bullshiting (although all the process is point towards a good experience, if you do this it won’t be, believe me).

So, this 3 reasons lead me to believe that publishing this is a win-win. You will probably learn something and by doing it have more chances on your future interviews, not by some kind of “cheat” but because you really know more. If you just use this to try to fool the interviewer it will be easy to tell and you will probably get yourself “blacklisted”.

Below you will find the questions that I talked above that I use during interviews. Remember, they won’t have a written answer: if you don’t know, research it!

This list isn’t static, it may change over time.

Don’t take the division of Junior SE, SE and Senior questions seriously. It only exists to provide a small guide to what may be interesting knowledge for each position, but it has no big logic applied to the division.

I also subdivided it 3 parts, Java, Android Theory and Android Practice. Why? Well, it seems like I really like to make sub-groups. Actually I use them to be easier to pick some from each group and have always a balanced set of questions.

A last very important note: These questions alone do not make a good interview guide.

My typical interview has the following parts:

  1. Say hi, introduce myself.. (and all that you read before)
  2. Explain the interview process and what will happens in the interview and in the following (if the person proceeds)
  3. Ask the interviewee to talk a bit about himself and his path so far (experience, past projects, personal projects, biggest challenges..)
  4. Go deep on past projects: implementation options, what were the biggest things that were learned and what would he do differently
  5. A little bit of theoretical questions (some of the ones below)
  6. Some practical questions
  7. Questions from the interviewee

Let’s focus on the bold points.

Theoretical questions

Junior SE Questions


  1. Name some of the characteristics of OO programming languages
  2. What are the access modifiers you know? What does each one do?
  3. What is the difference between overriding and overloading a method in Java?
  4. What’s the difference between an Interface and an abstract class?
  5. Can an Interface extend another Interface?
  6. What does the static word mean in Java?
  7. Can a static method be overridden in Java?
  8. What is Polymorphism? What about Inheritance?
  9. Can a constructor be inherited?
  10. Do objects get passed by reference or value in Java? Elaborate on that.
  11. What’s the difference between using == and .equals on a string?
  12. What is the hashCode() and equals() used for?
  13. What does the interface Serializable do? What about Parcelable in Android?
  14. Why are Array and ArrayList different? When would you use each?
  15. What’s the difference between an Integer and int?
  16. What is a ThreadPool? Is it better than using several “simple” threads?
  17. What the difference between local, instance and class variables?

Android Theory

  1. What is the structure of an Android Application?
  2. What’s the AndroidManifest file?
  3. What is an Activity in Android?
  4. Can you explain me how the lifecycle of an Activity works?
  5. What are “launch modes”? What types of launch modes are supported?
  6. What is a Fragment? Why are they useful?
  7. Are Fragments async or sync?
  8. Can you explain me how the lifecycle of a Fragment works?
  9. What’s a Dialog in Android?
  10. What’s a View in Android?
  11. Can you create custom views? How?
  12. What are ViewGroups and what’s their difference from a View?
  13. What are the most relevant attributes from a View that you remember?
  14. What’s an InputType?
  15. What is a Layout in Android?
  16. What different Layouts do you remember?
  17. What’s a FrameLayout? When should you use FrameLayout instead of RelativeLayout?
  18. What is the resources folder and what is it used for?
  19. What are permissions on Android?
  20. What is an Intent? How many different types do you know?
  21. How can I persist information in an Android device?
  22. What is a Service in Android? How many types of Services do you know?
  23. What is a ContentProvider and what do you use it for?
  24. What is a BroadcastReceiver?
  25. What is ADB?
  26. What is DDMS and what can you do with it?
  27. What is an AsyncTask? Elaborate.
  28. What is an ANR? How can you avoid it?
  29. How would you implement a list in Android?
  30. What is the support library? Why was it introduced?

Android Experience

  1. What have you used on Android? (Activities, Fragments..)
  2. Why did you use Fragments?
  3. Why should you avoid to run non-ui code on the main thread?
  4. How do you run “background” code? AsyncTask, Service, thread? Why?
  5. Down sides of AsyncTasks?
  6. How did you invoke your Activity back from the AsyncTask?
  7. What kind of layouts have you developed?
  8. What’s different about ConstraintLayout?
  9. How did you support different types of resolutions?
  10. If you use include in layouts can you override properties? Can every property be overridden ? (layout_*)
  11. How did you communicate between fragments and activities?
  12. What are some problems that can arise from Fragments being async?
  13. Have you used storage on Android? What kind?
  14. What do you use SharedPreferences for? Why?
  15. What do you use database for? Why?
  16. Did you develop using pure SQL or an ORM/lib ?
  17. Do you encrypt anything you store?
  18. How do you test your code?

Reactive/RxJava (2) Experience

  1. What’s the difference between a Observable and a Single?
  2. What about a Flowable?
  3. What is subscribeOn used for?
  4. What about observeOn ?
  5. What are the different subscribeOn and ObserveOn pools?
  6. What operations do you use the most?
  7. What is the difference between Observable.merge and Observable.combineLatest ?

SE Questions


  1. What is reflection?
  2. What is dependency injection? Can you name a few libraries? (Have you used any?)
  3. What are strong, soft and weak references in Java?
  4. What does the keyword synchronized mean?
  5. Can you have “memory leaks” on Java?
  6. Do you need to set references to null on Java/Android?
  7. What does it means to say that a String is immutable?
  8. What are transient and volatile modifiers?
  9. What is the finalize() method?
  10. How does the try{} finally{} works?
  11. What is the difference between instantiation and initialisation of an object?
  12. When is a static block run?
  13. Why are Generics are used in Java?
  14. Can you mention the design patterns you know? Which of those do you normally use?
  15. Can you mention some types of testing you know?

Android Theory

  1. What is Doze? What about App Standby?
  2. What can you use for background processing in Android?
  3. What is ORM? How does it work?
  4. What is a Loader?
  5. What’s AIDL in Android?
  6. What is proguard used for?
  7. Do you know what’s obfuscation? What is it used for? What about minification?
  8. What is the NDK and why is it useful?
  9. What is a PNG9 image? What about a SVG?
  10. What is the StrictMode?
  11. What’s the difference between flavors and project libraries? When would you use each?
  12. What is a BuildType in Gradle? What can you use it for?
  13. Why is it better to use Parcelable than Serializable in Android?
  14. What is Lint? What is it used for?
  15. What is a SurfaceView?
  16. What’s the difference between ListView and RecyclerView?
  17. What’s the ViewHolder pattern? Why should we use it?
  18. What are DiffUtils for (on the context of List adapters)?
  19. What is the XML tag animateLayoutChanges for?
  20. Is it possible to implement push notifications in Android? How?
  21. How can two fragments communicate?
  22. In what Thread does a Service run?
  23. Is a Context always from an Activity?
  24. What is a PendingIntent?
  25. What’s the best way to update the screen periodically?
  26. Can you manually call the Garbage collector?
  27. What are the different types of Broadcasts?
  28. What are the difference between the different types of Services?

Android Experience

  1. If you have a BroadcastReceiver defined, the method onReceive will run on which thread?
  2. How can you communicate between an object you want and your Service?
  3. Between binders, aidl, intents, local and global broadcast what is your preference and why?
  4. Do you know any ORM Android libraries? What are their advantages and disadvantages?
  5. Have you developed widgets? Describe.
  6. What Android/Java libraries have you used?
  7. Describe the architecture of your last app.
  8. How do you build your apps for release? Do you have a build server?
  9. Have you done unit testing or automatic testing?

Reactive/RxJava (2) Experience

  1. What’s the difference between a .map and a .flatMap?
  2. What would you use a .filter for?
  3. What’s a BehaviorSubject? What about a PublishSubject?
  4. What happens if you have multiple subscribeOn? And ObserveOn?
  5. Can you have multiple subscribers for the same stream?
  6. What is .share() for?
  7. Do you need to dispose of streams? When?
  8. How can you create your own Observable?
  9. What the difference between: doOnSubscribe, doAfterTerminate and doFinally?
  10. What happens if you add a Disposable to a CompositeDisposable that has already been disposed?
  11. In what cases would you need to use a Flowable?
  12. What is flattenAsObservable for?

Senior SE Questions


  1. How does Integer.parseInt() works?
  2. Do you know what is the “double check locking” problem?
  3. Do you know the difference between StringBuffer and StringBuilder?
  4. How is a StringBuilder implemented to avoid the immutable string allocation problem?
  5. What does Class.forName method do?
  6. What is Autoboxing and Unboxing?
  7. What’s the difference between an Enumeration and an Iterator?
  8. What is the difference between fail-fast and fail safe in Java?
  9. What is PermGen in Java?
  10. What is a Java priority queue?
  11. Is performance influenced by using the same number in different types: Int, Double and Float?
  12. What is the Java Heap?
  13. What is daemon thread?
  14. Can a dead thread be restarted?

Android Theory

  1. How does the Android GC works? (Mark Sweep Algorithm)
  2. When is a object eligible for garbage collection?
  3. What happens if a static variable is pointing to an Activity Context? What about for the Application Context?
  4. What happens if you have an Activity that triggers a Dialog or a Fragment while stopping (after onSaveInstance) ?
  5. Could you describe what each type of context can do? For example, can I start an activity with an Application Context?
  6. Can you think of a limitation on Proguard? How do you overcome them?
  7. What are the differences between Dalvik and ART?
  8. Do you know what’s the view tree? How can you optimize its depth?
  9. What is the onTrimMemory method for?
  10. Is it possible to run an Android app in multiple processes? How?
  11. Are SQL Injection attacks possible in Android? If so, how to prevent them?
  12. How does the OutOfMemory happens?
  13. What is a spannable?
  14. Does a fragment need a parameterless constructor? Why?
  15. What is renderscript? When would you use it?

Android Experience

  1. What did you did to guarantee modularity in your apps? Interfaces? Service providers? Break the project in several smaller libs? Use dependency injection? Elaborate.
  2. Do you know MVC, MVP, MVVM, MVI…? Elaborate
  3. Describe the architecture of your best app. Elaborate
  4. Do you know Aspect-oriented-programming? What would you use it for on Android?
  5. What do you think is a good process to implement continuous integration/delivery?
  6. If we needed to build a text messaging app, please describe me the architecture you would follow

Reactive/RxJava (2) Experience

  1. How can you define your own thread pool for each Scheduler?
  2. Why would you want to define your own thread pool for a Scheduler?
  3. How would you implement a flow where when a .flatMapIterable item fails, the flow continues with the next without failing them all?

Whiteboard (or laptop) exercises

  1. Write a method that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”
  2. Write a method that receives two strings, needle and haystack and without using .contains or .indexOf searches for the string needle on the string haystack and returns its index if it exists.
  3. Write a Java method to print Fibonacci series up to 100.
  4. Write Java method to reverse String in Java without using indexOf or contains.
  5. Write a Java method to find if a number is prime number or not
  6. How to find if a linked list contains cycle or not in Java
  7. Write a Java method to calculate Factorial of a number in Java
  8. Write a method that receives a number and prints the sum of all odd numbers until that one.
  9. Please write the output of those doOnNext:
val myRandomObservable = Observable.just("")
.doOnNext { Log.d(LOG_TAG, "[1] Which thread? -> " + Thread.currentThread().name) }
.doOnNext { Log.d(LOG_TAG, "[2] Which thread? -> " + Thread.currentThread().name) }
.doOnNext { Log.d(LOG_TAG, "[3] Which thread? -> " + Thread.currentThread().name) }
.subscribe({ Log.d(LOG_TAG, "[4] Which thread? -> " + Thread.currentThread().name) })

Follow up questions:

  1. If you were to put this code to production, what validations would you add?
  2. How would you (unit) test that method ?

(Initially I didn’t add the exercises section although I used a lot of those questions. After a lot of readers pointed that the above questions were more trivia like, I agreed and added this section to be more faithful to the real interview experience. It has also the same principle: if you study it at least you’ll learn more)

Interested in Kotlin?

Don’t miss the next chapter!

Not interested in Kotlin? So… after seeing all this how can you beat someone at his “own game”?

Well, I was going to write a bit more about how to address a question and answer “properly”. But I found someone who already did, so no need to repeat. Read this, and then come back.

Breath in, breath out…

This is not the end!

You shouldn’t definitely skip the last part, let’s proceed…

[Next Chapter — Aftermath]