Android Interview Questions And Answers

A set of questions that I have accumulated over the years in preparation for my many Android Interviews Prep.

1) What is Android?

Android is an open-source, Linux-based operating system used in mobiles, tablets, televisions, for more Android Online Training

2) What is the Android Application Architecture?

Android application architecture has the following components:
  1. Services − It will perform background functionalities
  2. Intent − It will perform the interconnection between activities and the data passing mechanism
  3. Resource Externalization − strings and graphics
  4. Notification − light, sound, icon, notification, dialog box and toast
  5. Content Providers − It will share the data between applications

3) What are the advantages of Android?

Open-source: It means no license, distribution and development fee.
Platform-independent: It supports Windows, Mac, and Linux platforms.
Supports various technologies: It supports camera, Bluetooth, wifi, speech, EDGE etc. technologies.
Highly optimized Virtual Machine: Android uses a highly optimized virtual machine for mobile devices, called DVM (Dalvik Virtual Machine.

4) Does android support other languages than java?

Yes, an android app can be developed in C/C++ also using android NDK (Native Development Kit). It makes performance faster. It should be used with Android SDK.

5)  Why would you do the setContentView() in onCreate() of Activity class?

As onCreate() of an Activity is called only once, this is the point where most initialisation should go. It is inefficient to set the content in onResume() or onStart() (which are called multiple times) as the setContentView() is a heavy operation.

6) Define Android toast.

An android toast provides feedback to the users about the operation being performed by them. It displays the message regarding the status of the operation initiated by the user.

7) Explain the use of 'bundle' in android?

We use bundles to pass the required data to various subfolders.

8) What is an application resource file?

The files which can be injected for the building up of a process are called an application resource file.

9) onSavedInstanceState() and onRestoreInstanceState() inactivity?

onRestoreInstanceState()

When an activity is recreated after it was previously destroyed, we can recover the saved state from the Bundle that the system passes to the activity. Both the create() and callback methods receive the same Bundle that contains the instance state information. But because the method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it. If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed.

onSavedInstanceState()

is a method used to store data before pausing the activity?

10) Can the bytecode be written in java be run on android?

No
11) List the various storages that are provided by Android.
The various storage provided by android are:
  • Shared Preferences
  • Internal Storage

12) How are layouts placed in Android?

Layouts in Android are placed as XML files.

13) How to call another activity in android?

Intent i = new Intent(getApplicationContext(), ActivityTwo.class);  
  1. startActivity(i);  

14)What is AAPT?

AAPT is an acronym for android asset packaging tool. It handles the packaging proces

15) Name some exceptions in Android?

  • Inflate Exception
  • Surface.OutOfResourceException
  • SurfaceHolder.BadSurfaceTypeException
  • WindowManager.BadTokenException To more Information visit android development course

16) Which types of flags are used to run an application on Android?

Following are two types of flags to run an application in Android:
  • FLAG_ACTIVITY_NEW_TASK
  • FLAG_ACTIVITY_CLEAR_TOP

17) Why bytecode cannot be run in Android?

Android uses DVM (Dalvik Virtual Machine ) rather using JVM(Java Virtual Machine).
18) Explain the build process in Android:
  1. First step involves compiling the resources folder (/res) using the aapt (android asset packaging tool) tool. These are compiled to a single class file called R.java. This is a class that just contains constants.
  2. Second step involves the java source code being compiled to .class files by javac, and then the class files are converted to Dalvik bytecode by the “dx” tool, which is included in the sdk ‘tools’. The output is classes.dex.
  3. The final step involves the android apkbuilder which takes all the input and builds the apk (android packaging key Android Online Training Hyderabad

19) Lifecycle of an Activity

  • OnCreate(): This is when the view is first created. This is normally where we create views, get data from bundles etc.
  • OnStart(): Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
  • OnResume(): Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it.
  • OnPause(): Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed.
  • OnStop(): Called when you are no longer visible to the user.
  • OnDestroy(): Called when the activity is finishing
  • OnRestart(): Called after your activity has been stopped, prior to it being started again Android Online Interview Question

20) What’s the difference between onCreate() and onStart()?

  • The onCreate() method is called once during the Activity lifecycle, either when the application starts, or when the Activity has been destroyed and then recreated, for example during a configuration change.
The onStart() method is called whenever the Activity becomes visible to the user, typically after onCreate() or onRestart












Comments

Post a Comment

Popular posts from this blog

Ten Things a Junior DBA Should Learn

SQL Server Interview Questions & Answers