1

Is it possible to have extras in intent-filter?

  • Yes
  • Yes because, it will check for matching extras of the intent
  • No, Intent-filter tag doesn't have extra tag at all.
  • Intent-filter has extra tag, but it is not mandatory to use it.

Answer: C No, Intent-filter tag doesn't have extra tag at all.
Description: intent-filter tag will not have extra tag. it has only action, category, and data tags. extra tag will not be used while performing tests for intent resolution.

2

What is the difference between menus and dialogs, in android?

  • menus are designed using xml, they will not change so frequently.
  • Dialogs are built using code as they frequently change the content.
  • both option 1 and option 2 are correct.
  • both option 1 and option 2 are wrong.

Answer: D option 1 and option 2 are correct
Description: Menus are designed using xml, because menus will not change so frequently. You can build menus using code also when ever required. But it is not recommended to completely build menus using code.
Dialogs are built using code because dialog content will frequently change.

3

How many types of menus are there in android?

  • SubMenu, OptionsMenu
  • SubMenu, OptionsMenu, ContextMenu
  • SubMenu, DialogMenu, ContextMenu
  • SubMenu, SubMenu, DialogMenu

Answer: B SubMenu, OptionsMenu, ContextMenu
Description: Options Menu - triggered when user presses menu hard key. This is deprecated starting from android 3.0. In place of options menu migrate to action bars.
Sub Menu - Menu with in a menu (only one level of sub menu is allowed).
Context Menu - Triggered when user press and hold on some view which was registered to show context menu.

4

How many types of dialogues are there in android?

  • AlertDialog, Context Dialog, Date & time picker dialog
  • AlertDialog, Progressdialog, date & time picker dialog
  • items dialog, progress dialog, date & time picker dialog
  • menu dialog, progress dialog, date & time picker dialog

Answer: B AlertDialog, Progressdialog, date & time picker dialog
Description: 1. AlertDialog - This is the most common form of any dialog, which will contain title, text, and maximum 3 buttons.
There in this 4 types of it - normal alert dialog, items alert dialog, single choice, & multi choice alert dialog.
2. ProgressDialog. - This is to show progress bar in the dialog box.
3. DatePickerDialog - This is to show date to pick.
4. Time picker dialog - This is to show time to pick.

5

What is the difference between getPreferences and getSharedPreferences in android ? To secure preference file from other activities in an android application, which one to use? getpreferences() or getsharedpreferences()?

  • getPreferences()
  • getSharedPreferences()
  • Use getPreferences(), but its not guaranteed to be protected as it will be stored with the name of Activity.
  • use getSharedPreferences(), but its not guaranteed to be protected as it will be stored with the name of Activity.

Answer: C Use getPreferences(), but its not guaranteed to be protected as it will be stored with the name of Activity.
Description: getPreferences(0) - will open or create a preference file with out giving a name specifically. By default preference file name will be the current Activity name. if some one knows this, any once can access getPreference() file using that activity name.
getSharedPreferences("name",0) - will open or create a preference file with the given name. If you want to create a preference file with a specific name then use this function. If you want multiple preference files for you activity, then also you can use this function.
Note: preferences file will be with .xml extension stored in data/data/preferences folder.

6

Open messaging application, start composing a message, press home button. Now start Gmail application. Will it create a new task or is it part of old messaging task?

  • it starts a new task
  • it is part of old task only
  • Neither it creates new task, nor it run in old. it runs in its own process
  • Neither it creates new task, nor it run in old. it runs in previous process.

Answer: A it starts a new task
Description: Once user presses home button, and if he launches any other application, then it will create a new task.

7

What is the difference between intent and intent-filter in android?

  • intent is a message passing mechanism between components of android, except for content provider.
  • intent-filter tells about the capabilities of that component.
  • option 1 and 2 are right.
  • option 1 and 2 are wrong.

Answer: C option 1 and 2 are right.
Description: intent : is a message passing mechanism between components of android, except for content provider.
you can use intents to pass data from one component to other component.
you can also use intents to start one component from other component. eg: you can start an activity by using intents.
intent-filter : tells about the capabilities of that component.
it tells what kind of implicit intents that component can handle.
intent-filters are counter parts for intents.

8

What is the difference between local variables, instance variables, and class variables?

  • local variables - declared in the class
    class variables - declared in function
    instance variables - declared in class which are static
  • local variables - declared in the function
    class variables - declared in class, non static
    instance variables - declared in class which are static
  • local variables - declared in the function
    class variables - declared in class, static
    instance variables - declared in class which are non static
  • local variables - declared in the class which are static
    class variables - declared in class, non static
    instance variables - declared in the function

Answer: C local variables - declared in the function
class variables - declared in class, static
instance variables - declared in class which are non static
Description: local variables - declared in the function
class variables - declared in class, static
instance variables - declared in class which are non static

9

what is the permission required to make a call in android, by using ACTION_CALL ?

  • android.permission.CALL_PHONE
  • android.permission.DIAL_PHONE
  • Intent.permission.CALL_PHONE
  • intent.permission.DIAL_PHONE

Answer: A android.permission.CALL_PHONE
Description: To make calls, we should have below permission tag in manifest file after application tag.
uses-permission android:name = "android.permission.CALL_PHONE"/.

10

what is the folder structure of android project in eclipse?

  • src -> contains source code files
    gen -> auto generated files by appt tool
    bin -> contains .class and apk files
    res -> contains all resource files
    drawable -> contains images used for project
    layouts -> contains layout xml designs
    values -> contains strings xml files
  • src -> contains source code files
    gen -> auto generated files by appt tool
    bin -> contains only .class files
    res -> contains all resource files
    drawable -> contains images used for project
    layouts -> contains layout xml designs
    values -> contains raw xml files
  • src -> contains only java files
    gen -> auto generated files by appt tool
    bin -> contains only apk files
    res -> contains all resource files
    drawable -> contains images used for project
    layouts -> contains layout xml designs
    values -> contains raw xml files
  • src -> contains source code files
    gen -> c files
    bin -> contains only .class files
    res -> contains all resource files
    drawable -> contains images used for project
    layouts -> contains layout xml designs
    values -> contains raw xml files

Answer: A src -> contains source code files
gen -> auto generated files by appt tool
bin -> contains .class and apk files
res -> contains all resource files
drawable -> contains images used for project
layouts -> contains layout xml designs
values -> contains strings xml files
Description: src -> contains source code files
gen -> auto generated files by appt tool
bin -> contains .class and apk files
res -> contains all resource files
drawable -> contains images used for project
layouts -> contains layout xml designs
values -> contains strings xml files

11

How intent and intent filter works in android? What are the sequence of tests done to map intent with an intent-filter?

  • action test
  • category test
  • data test
  • all the above tests

Answer: D all the above tests
Description: When programmer starts a component by using an intent, to trigger appropriate component android will perform 3 tests.
1.action test : the action string of intent should match with at least one action string of intent filter.
2.data test : data and data type of intent should match with that of intent filter.
3.category test : all the categories of intent should be there in intent filter.
note: In case of implicit intent starting an activity, then default category will be automatically added to intent.
If there is any component in manifest file with an intent filter which passes all the 3 tests, then android will trigger that component. Else not.
If there are multiple components satisfying that intent, and if it is not a broadcast receiver, then it will ask user to make a decision.

12

How to trigger a component which don't have any action in the intent filter, from outside of that application?

  • No, with out any action no one can trigger or start that component from outside world.
  • You can trigger that component from outside that application using explicit intent.

Answer: A No, with out any action no one can trigger or start that component from outside world.
Description: Without any action in the intent filter, it is not possible to start that component from outside world.
intent filters, action will be considered only for implicit intents.
Note: You can explicit intents only with in the application.

13

Is it possible to have multiple actions in an intent-filter?

  • No, intent-filter should have only one action.
  • they can have 0 or more number of actions.
  • they can have 0 or more number of actions. But if that component has only one intent-filter with 0 actions, then that component can be triggered using only explicit intents.
  • No, intent-filter should have only one action, because a given component should not perform more than one action.

Answer: C intent filters can have 0 or more number of actions. But if that component has only one intent-filter with 0 actions, then that component can be triggered using only explicit intents.
Description: intent-filters can have 0 - n number of actions, but if that component has only one intent-filter with 0 actions, then that component can be triggered using only explicit intents. a given intent-filter can have more than one action because, a given component can do more than one action. EG: notepad can perform two actions ACTION_VIEW & ACTION_EDIT on an existing note pad file.

14

Is it possible to have multiple categories in an intent-filter?

  • No, intent allows only one category
  • Yes, but intent should have at least one action along with those categories.
  • Yes, you can have n no of categories in it.
  • Yes, but you should have same no of actions also along with categories

Answer: C Yes, you can have n no of categories in it.
Description: Intent filter can have n number of categories.

15

how to see the action which has triggered/ started a component(activity)?

  • use getIntent().
  • use getAction() from the intent.
  • use getIntent() and then use getAction() from that intent.
  • Option 3 is true, but not always. some times you don't need to get the intent specifically.

Answer: D Option 3 is true, but not always. some times you don't need to get the intent specifically.
Description: Use getIntent() - then- getAction(). getIntent will give you the intent, from which you can fetch the action. but some times intent will be directly available in onNewIntent() function of the activity, in some scenarios. in that case you don't need to use getIntent() specifically.

16

I want to design an android application where I take username, password and connect to the Gmail and show the status of log in to the user. Now how to design this application? How many components will be there?

  • It needs one service with one worker thread, and one activity.
  • it needs one service, one activity.
  • It needs one service with multiple threads, and one activity.
  • It needs one service with one worker thread, and only one dialog in service.

Answer: A It needs one service with one worker thread, and one activity.
Description: To access user name, pw & to show login status in dialog we need - one Activity with dialog. To connect to Gmail server we need - one Service, with one thread.

17

Where do static variables gets stored?

  • stack
  • heap
  • data segment
  • hard disk

Answer: C data segment
Description: stack - stores local variables. heap - instance variables and new instances. data segment - will store all static variables. code segment - will store code.

18

how to create customized textview in android?

  • Yes it is possible. TextView t = new TextView(this);
  • No, you can't.
  • Yes, extend TextView class and create your own.
  • Yes, TextView t = findViewById(R.id.textView1);

Answer: D Yes, extend TextView class and create your own.
Description: TextView is a predefined UI control given by android. If you don't like or wanted to enhance its properties, then you can create your own class by extending TextView class and implementing your own functionalities.

19

What is the extension of shared preference file? Where do shared preference files will be stored? Which of the below options are correct?

  • i. extension of shared preference file is .xml, and shared preference files will be stored in sd card.
  • ii. extension of shared preference file is .xml, and shared preference files will be stored in internal memory.
  • iii. folder structure of preference file is data/data/preferences
  • i
  • ii
  • ii & iii
  • i & iii

Answer: C ii & iii
Description: shared preference files by default will be stored in internal memory of app. shared preference files extension is .xml. It is in the file structure of data/data/preferences. But this will not be visible to outside applications and phone users. they can't see what is available in apps internal memory allocated to it.

20

What is the default shared preference file name, when created with getPreferences?

  • Default.xml
  • Settings.xml
  • Activityname.xml
  • Preferences.xml

Answer: C Activityname.xml
Description: By default if programmer don't give any name to shared preference, then activity name will be taken as shared preference file with .xml extension.