1

Which kernel(Operating system) is used in android?

  • windows
  • linux
  • unix
  • ios

Answer: B linux
Description: Android is based on Linux 3.6 version.
Related questions:
Which linux kernel version is used in android?
What type of kernel is used in android?

2

Android framework is written in which language?

  • c
  • c++
  • java
  • .net

Answer: C Java
Description: Top two layers (application, and Framework layers) are written in Java. Where as drivers layer and library layer are written in c and c++.

3

What is the full form of DVM in Android?

  • Devices Virtual Memory
  • Dalvik Virtual Machine
  • Debuggable Virtual Machine
  • none

Answer: B Dalvik Virtual Machine
Description: The full form of DVM is "Dalvik Virtual Machine". This is the name of the virtual machine used in Android to run android applications. It is named after an island "Dalvik".

4

What is the difference between DVM and JVM? Why Android opted for DVM?

  • DVM is faster than JVM, and DVM is under free license.
  • Oracle did not allow Google to use JVM. So Google started using DVM for its android.
  • JVM was not free that's why android opted for DVM
  • JVM is not meant for java programs. Android uses java internally it can't use JVM in it. So Android opted for DVM.

Answer: A DVM is faster than JVM, and DVM is under free license.
Description: Android team preferred DVM over JVM because of below given reasons.
1. Though JVM is free it was under GPU license, which is not good for Android as most of the Android is under Apache license.
2. JVM was designed by keep desktops in mind. So it is too heavy for embedded devices.
3. DVM takes less memory, runs & loads faster compared to JVM.
4. Since mobile devices have lot of limitations like low CPU speed and less Memory, it is always better not to use heavy components like JVM.

5

Which layer does Dalvik Virtual Machine sit?

  • Driver layer
  • library layer
  • framework layer
  • application layer

Answer: B library layer
Description: Every android application runs in DVM. To run an application it requires memory, process, threads and other resources. But all these resources are under control of kernel. So DVM has to interact with driver layer for memory and thread management, it sits just above driver layer (that is.. it sits in library layer)

6

What is the latest android version? What are the new concepts added in that version?

  • 4.4
  • 4.3
  • 4.2
  • 3

Answer: A 4.4
Description: Latest version as on November 2013 is 4.4 that is KitKat. KitKat runs faster and smoother even in the low end devices which has mere 512 MB RAM.

7

What is the importance of version code and version name attributes in manifest file?

  • it will tell your activity's version no and name.
  • it tells your applications version number and name.other than this no use.
  • no use, it is just for our reference.
  • it tells your applications version number and name. It will be used when you want to update your app in google play store

Answer: D it tells your applications version number and name. It will be used when you want to update your app in google play store
Description: Version no and name will be useful when you upload some application to play store and wanted to update it. When you are upgrading your application then you can increment the version number so that users of your application will get notification on their phones about the latest updates available.

8

How many manifest files will be there in an android application?

  • maximum one is allowed
  • it can have multiple manifest files
  • 1 and 2, both are correct
  • 1 and 2 both are wrong

Answer: A maximum one is allowed
Description: every application will have only one manifest file which tells its capabilities.

9

Is it possible to create an activity without setContentView(R.layout.main) xml file?

  • Yes
  • No
  • None
  • Question Not correct

Answer: A Yes
Description: Yes, it is possible. You can create resources with code also, with out having your xml files.
For eg: below code will work with out setting xml file as the layout for your activity.
onCreate(...)
{
super.onCreate(..);
TextView tv = new TextView(this);
tv.setText("hello world");
setContentView(tv);
}

10

Give two examples for configuration changes in Android?

  • flipping the phone
  • keyboard on
  • language settings change
  • all of the above

Answer: D all of the above
Description: configuration changes include: rotating the phone, having virtual keypad on, and changing language settings in settings.

11

What is the difference between implicit intent and explicit intent, give one example?

  • Implicit intent - Intent with out target component name; Explicit intent - Intent with target component name.
  • Implicit intent - Intent with target component name; Explicit intent - Intent with out target component name.
  • Use implicit intent If you want to start one activity from other activity with in the same application.

Answer: A Implicit intent - Intent with out target component name; Explicit intent - Intent with target component name.
Description: Implicit intent - Intent with out target component name; Explicit intent - Intent with target component name.
EG: if we want to start a new screen or activity with in our application, then we clearly know what is that activity name because both activities are in same application. In such cases we will use explicit intent. Assume that we want to launch Gallery activity from our application, then we don't know exact name of that gallery activity because gallery is a different application, in that case we will use implicit intent with some matching actions.
Eg for Explicit intent: Intent in = new Intent(getApplicationContext(), SecondScreen.class); //target component name startActivity(in); Note: Explicit intents are specifically used to start other components of same application.
Eg for Implicit intent: Intent in = new Intent(); //no target component name in.setAction(Intent.ACTION_GET_CONTENT); in.setType("image/*"); startActivity(in); Note: Iplicit intents are specifically used to start components of other applications.

12

How many components are there in an intent?

  • action
  • data & data type
  • category and extras
  • all above three

Answer: D all above three
Description: Intent can have a.action, b.data and its type, c.category, d. extras, e.Target Component name, f. some extra flags.

13

Is it possible to give more than one action in an intent?

  • No. Intent should have only one action
  • Yes. Intent can have more than one action
  • No. Intent can have 0 or maximum one action.

Answer: C No. Intent can have 0 or maximum one action.
Description: Intent can have maximum one action, but it is not mandatory. some times it can have 0 actions also (in case of explicit intent). So an intent can have 0-1 actions.

14

Is it possible to give more than one category in a given intent?

  • No. Only one category is allowed
  • Yes. You can have 0 or n number of categories in intent
  • Yes. But you have to make sure that intent will have at least one category.

Answer: B Yes. You can have 0 or n number of categories in intent
Description: Unlike actions, an intent can choose to have 0 or n number of categories.

15

What is the importance of putextra method in Android? How is it different from setdata() ? any way both are passing data only ,then what is the difference?

  • Both putExtra(), and setData() are used for same purpose, to pass data to other component.
  • setData() - is to pass data on which to take action. putExtra() - is to send extra information about this intent.
  • setData() - is to send extra information about this intent. putExtra() - is to pass data on which to take action.
  • logically both are same, so one can omit setData(), and pass all data through putExtra() only.

Answer: B setData() - is to pass data on which to take action. putExtra() - is to send extra information about this intent.
Description: setData() - is to pass data on which to take action. putExtra() - is to send extra information about this intent.
EG: if one is starting an activity to perform ACTION_CALL, then he has to set number in setData(). this function will contain on which data target component has to take action. if one want to pass extra details also, then only use putExtra().

16

If I send a broad cast with implicit intent, and there is no matching intent-filter then what will happen?

  • compile time error
  • it will throw run time exception - BroadcastReceiverNotFoundException, and crashes if it is not handled properly.
  • Nothing will happen, some how it launches target component
  • Nothing will happen, but it will not launch any receiver.

Answer: D Nothing will happen, but it will not launch any receiver.
Description: Unlike startActivity() and startService(); sendBroadcast() will not throw any run time exception. If there are no target components available for this broadcast it will keep quiet. It is because in case of activity and service, action is yet to be performed but in case of broadcastReceiver action is already over and we are just informing it to every one.

17

What will happen if there is no action in an implicit intent, will it trigger any component?

  • Will pass the action test if intent-filter has at least one action.
  • Will pass the action test if intent-filter also doesn't have any action.
  • Will pass the action test only if intent has at least one action.
  • will pass the test if intent is explicit. In case of explicit intent it will test for intent resolution.

Answer: A Will pass the action test if intent-filter has at least one action.
Description: Will pass the action test if intent-filter has at least one action.

18

What will happen if an activity is started with implicit intent, and there is no matching intent-filter?

  • compile time error
  • it will throw run time exception - activityNotFoundException, and crashes if it is not handled properly.
  • Nothing will happen, some how it launches target component
  • Nothing will happen, but it will not launch any new screen.

Answer: B it will throw run time exception - activityNotFoundException, and crashes if it is not handled properly.
Description: for startActivity(intent), if there are no matching target components or activities, then it will throw run time exception - ActivityNotFoundException, and will crash the program if this exception is not handled.

19

How to make a phone call from an android application?

  • Intent in = new Intent(); in.setAction(Intent.ACTION_DIAL); in.setData(Uri.parse("tel:12345")); startActivity(in);
  • Intent in = new Intent(); in.setAction(Intent.ACTION_CALL); in.setData(Uri.parse("tel:12345")); startActivity(in);
  • Intent in = new Intent(); in.setAction(Intent.ACTION_CALL); in.setData("12345"); startActivity(in);
  • Intent in = new Intent(); in.setAction(Intent.ACTION_DIAL); in.setData("12345"); startActivity(in);

Answer: B Intent in = new Intent(); in.setAction(Intent.ACTION_CALL); in.setData(Uri.parse("tel:12345")); startActivity(in);
Description: Intent in = new Intent();
in.setAction(Intent.ACTION_CALL);
in.setData(Uri.parse("tel:12345"));
startActivity(in);

20

What is the difference between intent, sticky intent, and pending intent?

  • intent - is a message passing mechanism between components of android; Sticky Intent - Sticks with android, for future broad cast listeners; Pending Intent - Will be used when some one wants to fire an intent in future.
  • intent - is a message passing mechanism between components of android except for Content Provider; Sticky Intent - Sticks with android, for future broad cast listeners; Pending Intent - Will be used when some one wants to fire an intent in future.
  • intent - is a message passing mechanism between components of android except for Content Provider; Sticky Intent - Sticks with android, for future broad cast listeners; Pending Intent - Will be used when some one wants to fire an intent in future and may be at that time that app is not alive.
  • same as 3rd option, but sticky and pending intent are same.

Answer: C intent - is a message passing mechanism between components of android except for Content Provider; Sticky Intent - Sticks with android, for future broad cast listeners; Pending Intent - Will be used when some one wants to fire an intent in future and may be at that time that app is not alive.
Description: intent - is a message passing mechanism between components of android, except for Content Provider. You can use intent to start any component.
Sticky Intent - Sticks with android, for future broad cast listeners. For example if BATTERY_LOW event occurs then that intent will be stick with android so that if any future user requested for BATTER_LOW, it will be fired;
Pending Intent - If you want some one to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent. Eg: Booking a ticket at late night when your application is not running. In this scenario we will create a pending intent to start a service which can book tickets at late night and hand it over to Alarm Manager to fire it at that time.