Technical Questions and Answers

1.Explain the life cycle of an activity, in android?
   onCreate-> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()

2.What is the difference between px, dp, dip, and dpi ?
  px - pixels, dp - density independent pixels, dip - density independent pixels, sp - scale independent pixels

3.What is android:gravity attribute in the view tag?
  it is to align the view content either right/top/bottom/center with in that view.

4.What is the difference between linear layout and relative layout?
linear layout - arranges element in either vertical or horizontal fashion. 
Relative layout - arranges elements in relative to each other.

5.How to kill an activity?
i. finish()
ii.finishActivity(int requestcode)

6.what is the life cycle of an activity in case of configuration change or orientation change?
a)onPause() -> onSaveInstanceState() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
b)onPause() -> onSaveInstanceState() -> onStop() -> onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()
c)onPause() -> onSaveInstanceState() -> onStop() -> onDestroy()->onCreate() -> onStart() -> onRestoreInstanceState() -> onResume()


7.How many kinds of linear layouts are there in android?
horizontal & vertical linear layout

8.What is Bundle? What does it contain in onCreate() of your activity?
Bundle contain previous savedInstantceState

9.How to get image from gallery, in android?
Intent in = new Intent();
in.setType("image/*");
in.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(in, 0);

10.Name some list adapters?
array adapter, cursor adapter, expandable list adapter, etc..

11.When an activity is in stopped state, is it still in memory or not?
when onStop() is called, then activity is still in memory and all its states and variables are intact.

12.How to pass data between activities? let’s say pass user id, city, and password to next activity and display it.
Intent in = new Intent();
in.setAction("ACTION"); //this should match with other activity intent-filter
in.putExtra("uid","kalis");
in.putExtra("city","Chennai");
in.putExtra("pw","androidtips");

13.What is activity in android?
Each screen in android, with which user interacts is called as an activity.

14.What is a context in android?
a).It is an interface to global information of an application.
b).contexts are generally used to create a new components or objects, like views. 
c).Contexts are also used to start an activity, or service or a receiver.
d).There are two types of contexts, activity context(this) and applicationcontext. You can obtain application context by getApplicationContext() method.

15.What is pending intent in android?
An intent which will be fired or triggered at future point of time by some one else (esp Alarm Manager or Notification Manager) on behalf of your application.

16.What are the different screen sizes available or supported in android?
a).android supports 4 variants of screen sizes: small, normal, large, and extra large
b).xlarge screens are at least 960dp x 720dp resolution 
    large screens are at least 640dp x 480dp resolution 
    normal screens are at least 470dp x 320dp resolution 
    small screens are at least 426dp x 320dp resolution

17.Which method need to be called to shut down an activity, itself?
Finish()

18.What is base adapter?what are the functions available in it?
Base Adapter is a common base class for any adapter that can be used in both ListView and Spinner. Base adapter is an abstract class which implements both ListAdapter and SpinnerAdapter interfaces. While creating custom adapters, mostly programmers will extend this class.
Functions available in Base Adapter:
    1.getCount() 2. getItem() 3. getList() 4. getView()

19.Android debugging : What is a break point and how to watch variables while debugging android program?
break point breaks the execution. To see value either you can put cursor on it or right click on variables and add to watch

20.What is log? where to use log functions?
Log messages are used to debug the program.
Log.d() is debug log.
Log.i() - informative
Log.e() - error log
Log.w() - warning log
Log.v() - verbose log

1 comments:

Write comments
Unknown
AUTHOR
February 24, 2017 at 12:19 PM delete

wow very clear interview questions and its helpful for cracking interviews... thanks for sharing..

android training and placements

Reply
avatar