Current Android Release version:
Version Code: Pie
Version: 9
API level: 28

Android Interview questions

1) Which method is called only once in Fragment life cycle?
2) Explain Fragment life cycle? What is the use of Fragments?
3) What is Intent? Difference between Implicit and Explicit Intents?
4) How to Display Toast message in Asyctask in doInBackground method?
5) 
What is an Application Not Responding (ANR) error, and how can you prevent them from occurring in your app?
6) Retrofit vs Volley? Which is the best to use in android?
7) Glide vs Picasso? Which is more efficient?
8) If you nest a RelativeLayout inside a LinearLayout then which layout parameters will the RelativeLayout use?
        a. RelativeLayout.layoutparams
        b. Viewgroup.margin
        c. Viewgroup.layoutParams
        d. LinearLayout.layoutParams

9) In Photo sharing app, user receives new photo and a notification is created and the user clicks on the notification. What do you attach to the notification to open the app and show the user the photo?
        a. intent
        b. photoIntent
        c. PendingIntent
        d. Service

10) App that periodically checks if something is "working" What do you use?
        a. Wake lock with power manager
        b. setInexactRepeating
        c. Post Handler
        d. call set periodic timer

11) 
The user is in their text messaging app - they click share - how do you get your app to show up?
        a. intent service
        b. broadcast receiver
        c. register content observer to telephone
        d. register an intent filter

12) 
What is the difference between a fragment and an activity? Explain the relationship between the two?
13) 
What is difference between Serializable and Parcelable ? Which is best approach in Android ?
14) The last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the system memory. Usually, the system will call onPause() and onStop() before calling onDestroy(). 
Describe a scenario, though, where onPause() and onStop() would not be invoked?
15) What is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?
16) What is UI/Main thread in Android
17) When can you use Thread over Service?
18) Explain detail about your favorite android API?
19) Difference between Views and Fragments?
20) Why are 2 boot loaders used in Android
21) What is binder in Android
22) What’s the difference between onCreate() and onStart()?
23)  What are the various ways an Android developer can apply multi-threading to their app?
24) LinearLayout vs RelativeLayout
25) Describe image caching
26) What is the difference between a regular .png and a nine-patch image?
27) What is difference between Serializable and Parcelable? Which is best approach in Android?
28) What are the four essential states of an activity?

     
     The four essential states of an activity are:
  • Active – if the activity is at the foreground
  • Paused – if the activity is at the background and still visible
  • Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
  • Destroyed – when the activity process is killed or completed terminated
29) What is dp, sp, pt, and px?
30) Explain MVP? Advantages over MVC
31) Explain MVVM? Advantages over MVC and MVP
32) What are the things which you mention in Manifest File
33) Suppose your doInBackGround() is running, and you rotated your device,
What will happen?
34) Can we execute AsyncTask from another AsyncTask’s doInBackground() method?
35) Activity Life Cycle, in detail?
36) How will you send data between two Fragments
37) Difference between ListView and RecyclerView
38) Explain Job Scheduler in detail
39) Difference between notifyDataSetChanged and notifyItemChanged
40) What is the difference between Dynamic Receiver and Static Receiver. Which to use when?
41) Which lifecycle method gets called when A goes to B/come back to A?
      Activity Launch Modes with examples
42) Let’s say 4 activities are there A->B->C->D. How to launch A from D finishing in between activities?
43) 4 Activities are there A->B->C->D.How to finish application from D if none of the activities opened earlier finished till now?
44) How CLEAR_TOP flag intent works in android
45) Service vs IntentService?When to prefer which type of service?
46) Explain ways for Activity to activity communication/Activity to fragment communication/Fragment to fragment communication
47) How to make a service persist even after Application killed
48) How to handle Background service and execution limits with new Oreo Updates?
49) Why do we use Headless fragments?
50) Suppose you have 10 images to fetch from Server. What is the best way to fetch images?
51) Should we provide a context in presenter/Model? Answering yes/no is not enough. You have to provide a solution for it.
52) Why do we prefer Framelayout for Fragments?
53) How to make a custom view in android? Explain lifecycle methods.Difference between onLayout/onMeasure.
54) Have you ever faced any issue with SingleInstance launch mode or example if you have used it? Providing real-life examples are preferred more.
55) How to load Large Bitmaps? Handle Memory leaks and Sample sizing
56) How to retain data on orientation change? Explain lifecycle during orientation changes.
57) What the Fragment’s method setRetainInstance(boolean) does?
58) How to analyse and fix Activity transition flickering in android?

59) Main components of android 
60) What are Activities Life cycles, explain with an Example? 
61) Explain remote service. 
62) Explain pending intent. 
63) What is advantage of pending intent over intent? 
64) Explain Broadcast Receivers with an Example 
65) Explain content provider and content resolver. 
66) Explain content provider and content resolver with help of a sample code. 
67) What is .apk? How is it generated? 
68) What is .aidl file? Can we use any different name instead of .aidl and create interface using any commands? 
69) What are threads? 
70) What are the two ways of implementing threads and which is the better one? 
71) startBroadcast(), startOrderBroadcast() and startStickyBroadcast() 
72) What are the different states of a thread? 
73) Explain Widget in android? 
74) Explain about android runtime environment. 
75) What is a Launcher? 
76) Explain init.c with respect to Dalvik Virtual Machine? 
77) Explain Services?Different type of services? 
78) Explain aidl interface and its implementation? 
79) Explain remote service with examples? 
80) Explain intent filter and intents? 
81) If an activity ‘A’ starts activity ‘B’ and ‘B’ starts another activity ‘C’,what is the method to call to finish all activities? 
82) Explain startService() and bindService()? 
83) What is content Resolver?Is it a wrapper Class? 
84) What is the difference between content receiver and content Provider? 
85) Explain Service Lifecycle? 
86) Local service and remote service? 
87) What are Broadcast Receivers and how to register them statically and dynamically? 
88) What are Content providers and how do we access the data? 
89) What adb commands you have used? 
90) What is manifest file? What all are mentioned in AndroidManifest.xml
91) What is category,action and data in intents and how they work? 
92) Shared preference - how to get it? 
93) Android listview and adapters 
94) How android manage applications on low memory? 
95) Pass data across different applications 
96) How to start Activity of another application 
97) How to use Bundles and pass parameters? 
98) How to make an Activity to launch at start 
99) Can we have two launcher Activities? 
100) How to make onCreate execute multiple times? 
101) How to get intent in a newly launched Activity 
102) How to troubleshoot when adb is not detecting device 
103) List some adb commands 
104) If I want to save the state of activity,in which method of lifecycle , I have to store? 
105) When OnsaveInstantState method will be called? 
106) Difference between service and broadcast-receiver? 
106) Difference between Activity and view
107) What is Shared Preference and difference with normal preference
108) What are the killable methods in Activity life cycle?

109) Can Activity run in background? 
110) What is layout and what are the different types of layouts? 
111) What is the difference between linear and relative layout? 
112) Can linear layout be nested in relative layout and vice versa? 
113) How to position the layout? 
114) Diff b/w SimpleCursorAdapter and CursorAdapter 
115) What is Handlers and its implementation. 
116) How Library and frameWork layer communicating. 
117) What is JNI.How it works. 
118) Difference between cursor adapter and Simple cursor adapter. 
119) How do you debug your application.

120) What are the different types of launch modes in Android and How to declare for Activity?
121) What is Application class?
122) What is Context? How is it used? 
123) What is the structure of an Android Application?
124) What is the difference between a Fragment and an Activity? Explain the relationship between the two.
125) Why is it recommended to use only the default constructor to create a Fragment? 
126) How would you communicate between two Fragments? 
127) What is retained Fragment?
128) What is View in Android?
129) Difference between View.GONE and View.INVISIBLE?
130) What are ViewGroups and how they are different from the Views?
131) What is a canvas?
132) What is a SurfaceView?
133) What is Constraint Layout?
134) What is the difference between ListView and RecyclerView?
135) What is the ViewHolder pattern? Why should we use it?
136) What the difference between Dialog and Dialog Fragment?
137) What is a Sticky Intent?
138) Is it possible to run an Android app in multiple processes? How?
139) What can you use for background processing in Android?
140) How would you perform a long-running operation in an application?
141) Why should you avoid to run non-ui code on the main thread?
142) What are the problems in asynctask?
143) When would you use java thread instead of an asynctask?
144) What is a Loader?
145) Explain Looper, Handler and HandlerThread
146) How to persist data in an Android app?
147) What is ORM? How does it work?
148) How would you preserve Activity state during a screen rotation?
149) What are different ways to store data in your Android app?
150) What is a Spannable?
151) What is the onTrimMemory() method?
152) How does the OutOfMemory happens?
153) How do you find memory leaks in Android applications?
154) What is Doze? What about App Standby?
155) What is overdraw?
156) How did you support different types of resolutions?
157) What are the different protection levels in permission?
158) What is the Dalvik Virtual Machine?
159) What is the difference JVM, DVM and ART?
160) What is DEX?
161) Can you manually call the Garbage collector?
162) What is ADB?
163) What is Lint? What is it used for?
164) Why Bundle class is used for data passing and why cannot we use simple Map data structure
165) How do you troubleshoot a crashing application?
166) Explain Android notification system?
167) What is AAPT?
168) What is the best way to update the screen periodically?
169) HashMap, ArrayMap and SparseArray
170) What are Annotations?
171) What is the support library? Why was it introduced?
172) What is Android Data Binding? 
173) What are Android Architecture Components?
174) Describe how REST APIs work. What is REST?
175) Reverse Engineering an APK.
176) What is proguard used for?
177) About multiple apk for android application
178) What is obfuscation? What is it used for? What about minification?
179) onSavedInstanceState() and onRestoreInstanceState() in activity?
180) How will you pass data to sub-activities?
181) Explain Fragment Life Cycle?
182) When activity is moved to stopped state, then what will happen to the life cycle of a fragment which is in that activity?
183) Is Fragment Life Cycle dependent on Activity Life Cycle?
184) How to call context in Fragment?
185) Explain the parameters of onCreateView()?
186) android.app.Fragment vs android.support.v4.app.Fragment?
187) How many ways to call Fragment?
188) What is FragmentManager Class?

189) Difference between Activity vs FragmentActivity?
190) How to handle the backPress in Fragment?
191) How to Persist data between configurations changes?
192) What is Headless Fragment?
193) How to begin the transaction?
194) Difference in adding and replacing a Fragment?

What is Kotlin?

Kotlin is a general purpose, open source, statically typed “pragmatic” programming language for the JVM and Android that combines object-oriented and functional programming features. 

Kotlin is officially supported language for Android.

JetBrains, known for IntelliJ IDEA (Android Studio is based on IntelliJ IDEA), introduced the Kotlin language in 2011.

Android Latest versions and API levels

The code names match the following version numbers, along with API levels and NDK releases provided for convenience:
Code nameVersionAPI level
Pie9API level 28
Oreo8.1.0API level 27
Oreo8.0.0API level 26
Nougat7.1API level 25
Nougat7.0API level 24
Marshmallow6.0API level 23
Lollipop5.1API level 22
Lollipop5.0API level 21
KitKat4.4 - 4.4.4API level 19
Jelly Bean4.3.xAPI level 18
Jelly Bean4.2.xAPI level 17
Jelly Bean4.1.xAPI level 16
Ice Cream Sandwich4.0.3 - 4.0.4API level 15, NDK 8
Ice Cream Sandwich4.0.1 - 4.0.2API level 14, NDK 7
Honeycomb3.2.xAPI level 13
Honeycomb3.1API level 12, NDK 6
Honeycomb3.0API level 11
Gingerbread2.3.3 - 2.3.7API level 10
Gingerbread2.3 - 2.3.2API level 9, NDK 5
Froyo2.2.xAPI level 8, NDK 4
Eclair2.1API level 7, NDK 3
Eclair2.0.1API level 6
Eclair2.0API level 5
Donut1.6API level 4, NDK 2
Cupcake1.5API level 3, NDK 1
(no code name)1.1API level 2
(no code name)1.0API level 1

Abstract class in Java

A class that is declared with "abstract" keyword is called as abstract class.
A method that is declared as abstract and it does not have implementation is known as abstract method.

abstract class A{} 
abstract void checkStatus(); //no implementation

Important points to remember:
  • abstract classes can not be instantiated but it can be inherited
  • abstract classes can have both abstract and non abstract methods
  • If any one single method is abstract in class then whole class must be declared as abstract

Understanding final keyword in Java

In Java, final keyword can be used with variable, method, class

final variable:
  • we can not change value of final variable once it is initialized
  • if final variable not initialized (blank final variable) at the time of declaration, it must be initialized in constructor
  • A static final variable that is not initialized during declaration can only be initialized in static block.
final method:
  • final methods can not be overridden but methods can be inherited
final class:
  • final class can not be inherited
Basic points to remember:
  • All variables declared in interface are by default final
  • constructor can not be declared final
  • If method parameters are declared final then the value of these parameters cannot be changed
  • Local final variable must be initialized during declaration

Understanding Static keyword in Java

Static keyword can be used with variable, methods, block and nested class.

Static variable (Class variables):
  • static variable belongs to the class and can be accessed without creating instance of the class
  • static variables are initialized only once at the start of execution. These variables will be initialized first before initialization of any instance variables
  • only single copy of static variable is created and shared among all the instances of the class
  • static variable gets memory only once in class area at the time of class loading
Static method (Class methods):
  • static method belongs to the class and can be accessed without creating instance of the class
  • static methods can not access non static data member or can not call non static method. It can access only static data
  • "this" and "Super" can not be used
Static block:
  • It is used to initialize static data member
           static int a, b;
           static {
                   a = 10;
                   b = 20;
          }
  • static block will be executed before main method at the time of class loading
         class sample {
              static {
                      System.out.println("This will be executed before main");
              }
              public static void main(String args[]) {
                     System.out.println("Main method");
              }
         }

Static nested class:
  • Java does not allow you to create top level static class, only nested static classes are allowed
  • nested classes that are declared with static are called static nested classes

Android Jetpack

Google IO 2018 introduced Android Jetpack.

Android Jetpack is a set of libraries, tools and architectural guidance to help make it quick and easy to build great Android apps. It provides common infrastructure code so you can focus on what makes your app unique.

Android Jetpack is available from Android Studio 3.2.

Android Jetpack is backward compatible library supports till Android 4.4 versions



For more information: https://developer.android.com/jetpack/