Tag Archives: Android Source code

Android Interview Questions and Answers-Part 1

LOGO (1)

Here are some basic Android related interview questions and their respective answers :-


Q ) What is Android?

A) Android is a stack of software for mobile devices which includes an Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later transforms into .dex format files.


Q) Explain the Architecture of android ?

A)  Top -> Applications (Contacts, Browser, Phone, etc)

Below Applications -> Application Framework(Activity Manager, Window Manager, Content Providers, View System, Package manager,
Telephony manager, Resource, Notification, Location managers)

Below Application Framework -> System Libraries(Like Sqlite, webkit, SSL, OpenGL, Media Framework etc) & Android Runtime( Core Libraries and DVM)

Atlast Last -> Linux Kernel (which composed of drivers like display, camera etc.)


Q) What are the advantages of Android?

A)  The following are the advantages of Android :-

  • The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.
  • Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized
  • Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.


Q) What items are important in every Android project?

A) Followings are the essential items that are present each time an Android project is created:
– AndroidManifest.xml
– build.xml
– bin/
– src/
– res/
– assets/

Q) What is intent in Android?
A) A class (Intent) will describes what a caller desires to do. The caller will send this intent to Android’s intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and the Adobe Reader apps will be the perfect activity for that intent(class).

Q) What Programming languages does Android support for application development?
A) Android applications supports using Java Programming Language. which is coded in Java and complied using Android SDK.


Q) What’s the difference between class, file and activity in android?
A) Class – The Class file is complied from .java file. Android will use this .class file to produce the executable apk.
File – It is a block of resources, srbitrary information. It can be any file type.
Activity – An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.

How to implement a Button Click event in Android without onClickListener?

For this what you need to do is, just add a property in your XML. Lets see how this is done.

There is a property in the Button tag named ‘onClick’ which has to be give a name first as shown below.

We have two buttons . On first button onClick we will show a toast and on second button’s onClick we will show a promptbox (alertbox).

 android:text="Click here"


The Whole XML layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" >

 <Button android:id="@+id/btn"
 android:text="Click here"
 android:onClick="MyClickMethod" />

 <Button android:id="@+id/btn2"
 android:text="Click here for pop up!!"
 android:onClick="ShowPopUp" />



Now, lets look at the code. Here, we need to create a method with the same name as that of the name we have given as the property name (Here its MyClickMethod & ShowPopUp).

Within the method you can write what you want to do when the button is clicked. Here in my code, I’ve given a toast to be displayed when it is clicked on first button &  on second button’s onClick we will show a promptbox (alertbox).


Here is the code, just have a look.

package com.fundoocode.net;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class ButtonClickActivity extends Activity
	 /** Called when the activity is first created. */
	 public void onCreate(Bundle savedInstanceState) 


	 public void MyClickMethod(View v)
	      Toast.makeText(getApplicationContext(),"You clicked the first Button " , Toast.LENGTH_LONG).show();

	 public void ShowPopUp(View v)
		 Promptbox("Yahoo!!", "Prompt demo", ButtonClickActivity.this); 

		public static void Promptbox(String title, String mymessage, Activity activity) 
				new AlertDialog.Builder(activity).setMessage(mymessage).setTitle(title).setCancelable(false).setNeutralButton(android.R.string.ok,new DialogInterface.OnClickListener() 

					  public void onClick(DialogInterface dialog, int whichButton) 


			catch (Exception e)



The Out Put Screen looks like this before the button is clicked.


After the button is clicked, the screen looks like this.



Skip to toolbar