Android Interview Questions

Practice for Android interviews by solving TestDome questions. Our interview questions are used by more than 6,000 companies and 450,000 individual test takers.

Jobseekers: Certify Your Knowledge

Take a Certification Test

Companies: Use Our Tests for Screening

Buy a Pack Of Candidates

Try to solve 5 Android interview questions below. Hints can help you find answers to questions you are having trouble with.

1. Screen Orientation

Event handling
   
Easy  

Which of these methods are called when the screen changes orientation from portrait to landscape in Android?

(Select all acceptable answers.)

onCreate()
onStop()
onRestart()
onActivityResult()
onRestoreInstanceState()
   


2. Shared Preferences

UI
   
Easy  

Fill in the blanks, so that changes in the shared preferences are saved:

SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
Editor editor = pref.();
editor.putString("start_message", "Hello!");
editor.putString("end_message", "Goodbye!");
editor.();
   


3. User Layout

Linear Layout UI
   
Easy  

Consider the following image:

Fill in the blanks in the following layout so that it renders like the image above:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="User"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="Last login date"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="Address"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="Secondary address"/>
        </LinearLayout>
</LinearLayout>
   


4. Parcelable

Interprocess communication
   
Hard  

Which statements are true for the Parcelable interface?

(Select all acceptable answers.)

Parcelable can be used to serialize data into JSON.
Parcelable is used to marshal and unmarshal Java objects.
Parcelable relies on Java Reflection API for marshaling operations.
Any data type can be passed to another intent through the Parcelable interface.
Parcelable creates a large number of temporary objects.
   


5. Media Player

Multithreading
   
Hard  

Consider the following code:

@Override
protected void onResume() {
    super.onResume();
    mp = MediaPlayer.create(getBaseContext(), R.raw.sound);
    Thread timer = new Thread() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                Intent main = new Intent(Splash.this, MainActivity.class);
                startActivity(main);
                finish();
            } catch (InterruptedException e) {}
        }
    };
    timer.start();
    mp.start();
}

@Override
protected void onPause() {
    super.onPause();
    if (mp != null) {
        if (mp.isPlaying()) {
            mp.stop();
        }
        mp.release();
        mp = null;
    }
}

Select the statements that are correct if the wave file sound is 3 seconds long.

(Select all acceptable answers.)

MainActivity will be started after 4 seconds.
finish() will close the current activity.
While MediaPlayer is playing, startActivity(main) is blocked.
MediaPlayer will play only the first second of the song.
Removing the call to startActivity(main) will close the application if there are no other activities in the application's back stack.
   


If you feel ready, take one of our timed public Android Interview Questions tests:
Android

Android Online Test (Easy / Hard)

Android and Java Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.