Saturday, January 3, 2015

250 Android Interview Questions - part 2

I am giving set of 250 Android interview questions here, which I have answered in android interview questions and answers - skillgun

Since Java is also a part of android interview, I have included around 60 java interview questions here.

I am giving only questions here as space is a constraint for explaining every answer.
                                            
Android Interview Questions:

101.                        I want to store huge structured data in my app that is private to my application, now should I use preferences [or] files [or] sqlite [or] content provider?
102.                        My application has only a service, and my service performs heavy lift functionality to connect to internet and fetch data, now should I create a thread or not? If so why?
103.                        I want to write a game where snake is moving in all the directions of screen randomly, now  should I use existing android views or should use canvas? Which is better?
104.                        Can I have more than one thread in my service? How to achieve this?
105.                        When lcd goes off, what is the life cycle function gets called in activity?
106.                        When a new activity comes on top of your activity, what is the life cycle function that gets executed.
107.                        When a dialog is displayed on top of your activity, is your activity in foreground state or visible state?
108.                        When your activity is in stopped state, is it still in memory or not?
109.                        When your activity is destroyed, will it be in memory or moved out of it?
110.                        I started messaging app –> composer activity -> gallery  -> camera -> press home button. Now which state camera activity is in?
111.                        Continuation to above question, now If I launch gmail application will it create a new task or is it part of old messaging task?
112.                        Can I have more than one application in a given task?
113.                        Can I have more than one process in a given task?
114.                        Do all the activities and services of my application run in a single process?
115.                        Do all components of my application run in same thread?
116.                        How to pass data from activity to service?
117.                        How to access progress bar from a service?
118.                        What is the difference between intent and intent-filter?
119.                        What is the difference between content-provider and content-resolver?
120.                        What is the difference between cursor & contentvalues ?
121.                        What is Bundle? What does it contain in oncreate() of your activity?
122.                        When an activity is being started with an intent action “MY_ACTION”, how can I see that action in triggered component(activity)?
123.                        How to get contact number from contacts content provider?
124.                        How to take an image from gallery and if no images available in gallery I should be able to take picture from camera and return that picture to my activity?
125.                        What is the difference between linear layout and relative layout?
126.                        How many kinds of linear layouts are there?
127.                        What is “dp” [or] “dip” means ?
128.                        What is importance of gravity attribute in the views?
129.                        What is adapter? What is adapter design pattern?
130.                        What is adapterview? How many adapter views are available in android?
131.                        Can you tell me some list adapters?
132.                        Can I give cursor to an array adapter?
133.                        What is custom adapter, when should I use it. what are the mandatory functions I need to implement in custom adapter?
134.                        What is the class that I need to extend to create my own adapter?
135.                        What is the android compilation and execution process/ cycle?
136.                        What is adb? What is the command to install one application using adb command prompt?
137.                        What is the debugging procedures available in android?
138.                        How will you analyze a crash, how will fix using logcat?
139.                        What is a break point and how to watch variables while debugging?
140.                        What is ddms? What are the various components in ddms?
141.                        What is the difference between started service and binded service?
142.                        How to achieve bind service using IPC?
143.                        How will I know if a client is connected to a service or not?
144.                        I want to access a functionality from one application to other application, then should I use content provider or startservice or bind service?
145.                        I want to access data of another application in my application, now do I need to implement content providers in my application or other application has to implement it?
146.                        What is the difference between local variables, instance variables, and class variables?
147.                        What is anonymous class? Where to use it?
148.                        What is singleton class, where to use it? show with one example how to use it?
149.                        If I want to listen to my phone locations, what all the things I need to use? Is it better to use network providers or gps providers?
150.                        My phone don’t have network signal and satellite signal, now is there any way to fetch my last location where signal was available?
151.                        I have some data available in docs.google server, and I want to display it in tabular fashion, tell me the sequence of steps to achieve this?
152.                        If I want to start some heavy weight functionalities that takes lot of battery power like starting animation or starting camera, should I do it in oncreate() or onstart() or onresume() of my activity? And where should I disable it?
153.                        Why you should not do heavy functionality in onresume and onpause()  of your activity?
154.                        What things I can do in onrestart() of my activity?
155.                        What is the life cycle of a service?
156.                        What is the life cycle of a broadcast receiver?
157.                        What is the life cycle of a content provider?
158.                        What is the life cycle of a thread?
159.                        What is the life cycle of your application process?
160.                        How to kill one activity?
161.                        What is log.d ? where to use log functions?
162.                        Draw the life cycle of an activity in case of configuration change?
163.                        What is the difference between viewgroup and layout?
164.                        Draw the key event flow in android?
165.                        When you fire an intent to start with ACTION_CALL , what is the permission required?
166.                        What are the permissions required to obtain phone locations?
167.                        How many levels of security available in android?
168.                        How to achive security to your service programmatically in such a way that your service should not get triggered from outside applications?
169.                        What are the sequence of tests done to map intent with an intent-filter?
170.                        Describe various folders in android project in eclipse?
171.                        What is raw folder in eclipse project?
172.                        Under what thread broad cast receiver will run?
173.                        If I want to notify something to the user from broadcast receiver, should I use dialogs or notifications? Why?
174.                        Can you create a receiver without registering it in manifest file?
175.                        If I want to broadcast BATTERY_LOW action, should I use sendbroadcast() or sendstickybroadcast? Why?
176.                        If I want to set an alarm to trigger after two days, how should I implement it? assume that I may switch off the phone in between.
177.                        I want to trigger my broadcast receiver as long as my activity is in memory, else it should not get triggered, how should I achieve this?
178.                        What is sleep mode? What will happened to CPU once screen light goes off?
179.                        How many kinds of wake locks are available, which one to use when?
180.                        If I am using full wake lock and user presses screen lights off, what will happen?
181.                        When phone is in sleep mode, what are the two components that will keep running even though phone is in sleep mode?
182.                        Every day night at 12 o clock I need to post some images to facebook, in that case I will set repeating alarm for every day night 12 am. But to upload images I want to start service, how should I do this ?
183.                        When you start an activity from a notification, will it start as new task or old task?
184.                        Why android follows single threaded ui mode? How other threads can manipulate ui views?
185.                        What is the purpose of SQLiteOpenHelper?
186.                        What is the procedure to upgrade database after first release?
187.                        Show with one example where memory leak possibility in Android?
188.                        If I want to write one application for both phones and tablets, what should I use in my UI?
189.                        I have a thousands of items in my array, and I want to display it in listview, what is the most optimized way to achieve this?
190.                        What is r.java file? What does it contain?
191.                        Write one application which will get triggered immediately after booting.
192.                        What does .apk  file contains?
193.                        How will pass information from one activity to other activity, let’s say pass userid, city, and password to next activity and display it.
194.                        Write code for an xml file having a relative layout with employee registration form.
195.                        Get a table information from the database and show it in table UI format.
196.                        I have thousands of columns and thousands of rows to display it in UI tabular format, how should I show it this dynamically growing UI. Should I load all in single shot or any optimization can be done?
197.                        When to use String, StringBuffer, & StringBuilder?
198.                        What is String constant pool? What is the difference between below two statements? 
                                                               i.      Which is preferred way to use?
                                                             ii.      String str1 = “hi”;
                                                            iii.      String str2 = new String(“hi”);
199.                        If I want to share a String between two threads, and none of threads are modifying my String which class I have to use?
200.                        If I want to use my String within only one thread which is modifying my String, then which class I have to use? Similarly if I want to my string to be changed by more than one thread then which class I have to use?
201.                        How does String class look like? What is final class meant for? How will you implement your own String class?
202.                        What is immutable object? How is it different from immutable class?
203.                        Depict one example for immutable class in java framework?
204.                        How will you write a class in such a way that it should generate immutable objects?
205.                        Does String class uses character array internally in its implementation?
206.                        What is the difference between char & Character classes? Which one is value type and which one is ref type?
207.                        What is the meaning of pass by reference? If I have an integer array and if I pass that array name to a function, is it pass by value or pass by reference?
208.                        I want to use array in my program which has to grow dynamically, in that case should I use Array [or] ArrayList [or] Vector? What is the difference between arraylist and vector? Which one of them is not part of collections framework of JAVA?
209.                        I want to use dynamically growing array shared between two threads, should I use arraylist or vector?
210.                        I want to store values of my employees in a data structure using java collections framework in such a way that I should be able to read, write, modify & delete them very fastly. Which datastructure should I use ? arraylist [or] linkedlist [or] hashsets [or] hashmap ?
211.                        Write a program in such a way that Thread1 will print from 1-1000 & Thread2 will print from 1000-1. Thread1 should sleep for 1 second at every 100th location. Thread2 should interrupt thread1 once thread2 reaches 500.
212.                        How will you stop a thread, which is currently running?
213.                        If Thread1 interrputs Thread2, how Thread2 should handle it? (Generally how threads should handle interruptions?) how will thread2 know that other threads are interrupting it?
214.                        What is interrupted exception? Which functions will throw this exception? How to handle it?
215.                        Assume that two threads t1, & t2 are running simultaneously in single core CPU. How does t2 will request OS that it wants to wait till t1 is finished?
216.                        I want to implement threads in my program, should I extend Thread class or implement Runnable interface? Which one is better, justify your answer in terms of design.
217.                        What will happen if you return from run() function of your thread?
218.                        What is the difference between checked  & unchecked exceptions? Which one programmer should handle?
219.                        arrayIndexOutOfBounds, NullPointerException, FileNotFoundException, ArithmeticException, InterruptedException, IOError, IOException. In this list which exceptions programmer has to handler compulsorily? Categorize above exception list into ERROR/ RUNTIME EXCEPTION/ REST categories.
220.                        Assume that I am writing a function which likely to throw checked exception, in that case if I don’t handle it will compiler throw any error?
221.                        How one should handle checked exceptions? Mention 2 ways to handle it.
222.                        I am writing a function where it is likely that checked exception may come, I want to handle it in my function and I want to pass that exception to my parent caller also. How do I achieve it?
223.                        What is difference between throw, throws?
224.                        Can I write a try block without catch statement?
225.                        What is difference between final, finally, & finalize.
226.                        Will java ensure that finalize will be executed all the time immediately after object is destroyed? How to mandate it?
227.                        What is 9 patch image, how is it different from .png images? Why we have to use this in android? How will it help in the scalability of an image for various screens?
228.                        What is the difference between synchronized method and synchronized block? If I have a huge function where only two lines of code is modifying a shared object then should I use synchronized block or method?
229.                        Implement insertion sort, binary search, and heap sort.
230.                        How many ways a server can communicate (Send data) to a mobile application? Which is fastest way json or xml?
231.                        What is JSONArray & JSONObject. Show this with one example by requesting one URL using HTTP, which gives JSON object.
232.                        Name some sites which extensively use JSON in communicating their data with clients.
233.                        What is the permission you need to take for fetching GPS locations, & reading contacts. Where will you have to write permissions in manifest file?
234.                        How will you display data base information in a table kind of architecture in android? Which view will you use?
235.                        How many kinds of adapter-views, and adapters available in android?
236.                        What is notifydatasetchanged() function meant for?
237.                        Take data base cursor of employee (eno, ename, salary) into a cursor, fill into a list view where each item should have a check box also, how will you implement it in android?
238.                        What is the difference between constructor and static block. Can I initialize static variables in constructor?
239.                        I want to use a private variable of Class-A in classB directly without using any function. How to achieve this?
240.                        I want to create a class in such a way that nobody should be able to create object for that class except me. How to do it?
241.                        Can I access instance variables in a static function? Can I access static function /variable from an instance method?
242.                        Why is multiple inheritance of classes not allowed in java? If I want to get functions of Class-A & Class-B into class-C. how do I design this program?
243.                        Does java allow multiple inheritance of interfaces? Can one interface extend other interface ? when should I extend interface from other interface?
244.                        What is the difference between over loading and over riding?
245.                        Can I over ride base class constructor in derived class?
246.                        Can I over load a constructor?
247.                        How does default constructor look like? What super() call does in a constructor?
248.                        Why does base class constructor gets executed before executing derived class constructor? Justify this with appropriate example?
249.                        How will you achieve dynamic polymorphism using over riding? Justify usage by taking some example (note: use client-server example)
250.                        Why overloading is static polymorphism, justify your answer?
251.                        What is the difference between static/compile time linking & dynamic/run time linking? Are static functions dynamically linked?
252.                        Show one Is-A relation with one example.
253.                        Show one Has-A relation with one example.


Happy job hunting
      Best wishes
          Team,
Palle Technologies
enquiry@techpalle.com
Phone : 080 - 4164-5630The training expert in Bangalore.

5 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. Nice post my friend. Would you like to make some guest post for my site
    Android Tutorial Point ?

    ReplyDelete