Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android interview questions and answers

1
Explain the life cycle of an activity, in android?
  1. Below cycle is always true.
    onCreate-> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()
  2. Below cycle executes always.
    onCreate-> onStart() -> onRestoreInstanceState() -> onResume() -> 
    onSaveInstanceState() -> onPause() -> onStop() -> onDestroy()
  3. Below cycle executes always.
    onCreate-> onStart() -> onResume() -> onStop() -> onPause -> onDestroy()
  4. Below cycle executes always.
    onCreate-> onStart() -> onRestoreInstanceState() -> onResume() -> 
    onPause() -> onSaveInstanceState() -> onStop() -> onDestroy()
Show Answer
Share Facebook gmail Twitter
2
In Activity's onCreate function, What is the purpose of super.oncreate() ?
  1. It gives permission to use your phone screen
  2. it calls super class constructor
  3. it does nothing , simply a return statement will be there in super class
  4. it will create graphical window for sub class.
Show Answer
Share Facebook gmail Twitter
3
Is it mandatory to implement oncreate() & onstart() of activity life cycle ? Will it run if those life cycle methods are removed?
  1. it gives compile time error
  2. run time exception, supernotcalled
  3. nothing will happen it will run perfectly
  4. your phone will hang
Show Answer
Share Facebook gmail Twitter
4
Is it possible to have an Activity without UI?
  1. not possible
  2. yes, if it is doing some functionality with out UI
Show Answer
Share Facebook gmail Twitter
5
How to start an activity to get response? Or How to start an activity to get result?
  1. startActivityOnResult()
  2. startActivityForResult()
  3. startActivity()
  4. setResult()
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
7
Activity life cycle: When a new activity comes on top of your activity completely, then what is the life cycle function that gets executed in the old activity?
  1. it calls onPause()
  2. it calls onPause() -> then -> onStop()
  3. it calls onPause() -> then -> onStop() -> onDestroy()
  4. it calls onPause() -> then -> onSaveInstanceState()
Show Answer
Share Facebook gmail Twitter
8
Activity life cycle: When a dialog is displayed on top of your activity, is your activity in foreground state or visible state?
  1. it calls onPause()
  2. it calls onPause() -> then -> onStop() -> onDestroy()
  3. it calls onPause() -> then -> onStop()
  4. it calls onResume()
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
What is the intent-filter of main activity that launches your application's main screen?
  1. <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
  2. <intent-filter>
                    <action android:name="Intent.MAIN" />
                    <category android:name="Category.LAUNCHER" />
                </intent-filter>
  3. It will not have any intent-filter by default.
  4. <intent-filter>
                    <action android:name="android.intent.action.LAUNCHER" />
                    <category android:name="android.intent.category.MAIN" />
                </intent-filter>
Show Answer
Share Facebook gmail Twitter
13
How to create UI (user interface) without using xml file? Show with one example on how to create a button without having xml file?
  1. @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
  2. @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Button b;
            setContentView(b);
        }
  3. @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Button b = new Button(this);
            setContentView(b);
        }
  4. @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Button b = findViewById(R.id.button1);
            setContentView(b);
        }
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
15
Activity life cycle onStop: Can I save all my databse table updates in onStop() of activity? If not explain why and also explain where should I save db tables?
  1. Yes we can.
  2. No, save it in onSaveInstanceState
  3. No, because onStop will never be called
  4. No, because onStop() may not be called in some situations.
Show Answer
Share Facebook gmail Twitter
16
What is difference between persistent data and transient data?
  1. Persistent data is temporary data, eg: creating an array in the program.
  2. transient data is temporary data, that we store in database tables
  3. Persistent data is permanent data that we store, eg in database tables, and transient data is logical data that we use in programming logic.
  4. reverse of option 3
Show Answer
Share Facebook gmail Twitter
17
What will happen if super.oncreate() from oncreate() function of activity is commented?
  1. Compile time error
  2. Run time exception, super not called.
  3. Nothing will happen, it will still execute with empty windos
  4. nothing will happen, it will execute with proper output
Show Answer
Share Facebook gmail Twitter
18
What is the difference between this context and getapplicationcontext ? which one to use when?
  1. no difference, both are same
  2. this points to entire process, appcontext points to current class.
  3. this points to current context, application context points to entire process. if your context is of entire life time of process then use app context, else this.
  4. both option 2 and 3 are correct
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :