1

How to simulate SD card with emulator?

  • you have to use real device to work with sd card.
  • by default all emulators will have sd card enabled.
  • we have to edit the emulator using avd manager and use sd card option check and set the memory for it.
  • none of the above.

Answer: C we have to edit the emulator using avd manager and use sd card option check and set the memory for it.
Description: We can simulate SD card with emulator using SD card check option in emulator settings in AVD manager.

2

What is the base class for any android application?

  • Activity
  • Application
  • Manifest
  • Applet

Answer: B Application
Description:

3

What is android ndk?

  • i. The NDK is a toolset that allows you to implement parts of your ANDROID app using native-code languages such as C and C++.
  • ii. using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app.
  • iii. A good example for using NDK can be a CPU intensive works which doesn't allocate much memory like signal processing, physics simulation etc.
  • i
  • i & ii
  • i,ii, & iii
  • none

Answer: C i,ii, & iii
Description:

4

Which of the important device characterstics that you should consider asyou design and develop your application ?

  • i. Screen Size and Density
  • ii. Input Configurations
  • iii. Platform Version
  • iv. Device Feature
  • i
  • i and ii
  • i, ii, iii
  • All
5

What is 9 patch tool in android?

  • i. we can set scaling factor on x, y directions of our image using this tool. This is to make sure that image will be stretched & compressed properly based on screen sizes.
  • ii. we can set scaling factor on x, y directions of our image using this tool. This is to make sure that content of the image is fitting in proper position in the view.
  • iii. we can set padding factor on x, y directions of our image using this tool. This is to make sure that content of that image will be aligned properly.
  • iv. we can set padding factor on x, y directions of our image using this tool. This is to make sure that image will be stretched & compressed properly based on screen size.
  • i
  • ii
  • i & iii
  • i & iv

Answer: C i & iii
Description: Generally when we use some images in our projects as background for some views, and that application is downloaded into various devices with different screen sizes, then based on the screen sizes that image will stretch and adjust it self to the scree sizes.
But the problem is, when the image gets stretched to fit the screen size, some times the resolution of the image gets damaged and will not look good in bigger screen devices.
To avoid this problem, we use 9 patch tool.
Using 9 patch tool, we can set scaling factor on x, y directions of our image using this tool. This is to make sure that image will be re sized properly based on screen sizes. And we can also set padding factor on x, y directions of our image using this tool. padding factor is to make sure that content of that image will be aligned properly in the image.

6

What is the difference between parcelable and serializable?

  • Parcels are light weight serializables. It is preferred to use parcels for marshaling objects into byte streams.
  • seializable objects are faster to transfer when compared to parcelables.
  • Android app heavily depends on Serialization concept to marshal objects.
  • Android uses Linux IPC driver to transfer data between two processes.

Answer: A Parcels are light weight serializables. It is preferred to use parcels for marshaling objects into byte streams.
Description: These concepts are related to Inter Process Communication (IPC).
When sending data between two applications, we have to make sure that both applications should understand the format of the data that is being sent.
Especially when you are sending non primitive data type values like classes and objects between two applications, We have to convert them into Operating System understandable format. O.S understands only primitive types (ints, chars etc). The reason for conversion is we have to O.S communication channel to transmit the data.
This process of converting Non primitive types to primitives and sending across to other application over some communication channel is called as Serialization. The reverse process is called as De Serialization.
In Java, IPC depends heavily on Serializables for serialization. But serialization is designed by keep desktop applications in mind. When you are doing IPC in mobile applications we have to make sure that the process of IPC is not too heavy.
In simple terms serialization is a heavy concept for IPC.
So in place of Serialization Android opted for Binders for achieving light weight Inter process communication. Binders internally depends heavily on parcels, to do the IPC.
Parcels are light weight serializables. It is preferred to use parcels for marshaling objects into byte streams.
Note: Binder IPC heavily depends on Shared memory concept to make sure that there is not much data duplication while sharing between applications.

7

How to store images of an activity into android phone gallery?

  • Use file system APIs to store iamges or files in the gallery application.
  • MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription);
  • ContentValues values = new ContentValues();
    values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(Images.Media.MIME_TYPE, "image/jpeg");
    values.put(MediaStore.MediaColumns.DATA, filePath);
    context.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
  • you can uses both option 2 and 3

Answer: D you can uses both option 2 and 3
Description:

8

What are the characteristics of Loaders ?

  • i. They provide asynchronous loading of data.
  • ii.They are available to every activity and fragment.
  • iii. They monitor the source of their data and deliver new results when the content changes.
  • iv. They automatically reconnect to the last loader's cursor when being recreated after a configuration change.Thus they don’t need to requery their data.
  • i
  • i and ii
  • i, ii, iii
  • All
9

What is JNI ?

  • Java Network Interface used for low level Java programming.
  • Java Native Interface that enables Java to call native application written in C,C++.
  • Java Network Interchange used for Java networking.
  • None are correct.

Answer: B Java Native Interface that enables Java to call native application written in C,C++.
Description:

10

What is the interface Spannable used for ?

  • Manipulate text that can span across multiple pages.
  • String parsing.
  • Manipulate text that can span across multiple textview windows.
  • This is the interface for text to which markup object can be attached and detached.

Answer: D This is the interface for text to which markup object can be attached and detached.
Description:

11

How to make an android application compatible with phone and tablet? What components should be used when writing an application targeting for both mobile phones and tablets?

  • i. Activity
  • ii. Fragment
  • iii. 9 patch tool
  • iv. for layouts don't use absolute layout. preferred to use Relative layout. Also while mentioning width/ height/ or margins don't mention in hard coded dp's or pixels, mention with respect to its parent.
  • i
  • i & ii
  • i, ii, & iii
  • i, ii, iii, & iv

Answer: D i, ii, iii, & iv
Description: Compatibility : Is to create an application targeting for both mobiles and tablets efficiently (keeping space and size in mind).
For that we have to use
1.Activities
2. Fragments. (To use space efficiently in tablets)
3. Since device screen sizes may vary, we have to make sure that our images used in that application should re-sized properly for all screen sizes. This can be achieved using draw9patch tool. (9 patch images)
4. We have to minimize the usage of absolute layouts and hard coded pixels in the xml layout files. Because if we use absolute pixels then it won't look proper when screen sizes changes. We should always mention the pixels in terms of screen width and height in which our application is downloaded. This can be done by using dp (density independent pixels).

12

Which of the below options are used to solve compatibility issues when using an Android app with both tablets and phones.

  • Fragments
  • 9 patch tool
  • avoiding using hard coded size for margins, heights, and widths.
  • all of the above.

Answer: D all of the above.
Description: Compatibility issues generally arise when our application is downloaded into devices with different screen sizes and screen resolutions. So first basic problem may come in case of tablets as activity don't use space efficient, so we have to sue fragments also. second problem may come in image scaling and re-sizing, so we have to use 9patch tool. third problem may come if we use hard coded or absolute pixels in xml layout files, so avoid it.

13

What is true about a Context?

  • i. Activity will have its own Context.
  • ii. Service will have its own Context.
  • iii. I can access activity's context directly from anonymous inner classes like button click listeners.
  • i
  • i & ii
  • i, ii, & iii
  • none

Answer: B i & ii
Description: Both activity & service will have its own contexts.
Note : You can't access activity's context from an inner class directly, rather you have to use ActivityName.this to access its context.

14

How to avoid memory leaks in android,in case if it occurs because of a link between static variable & and a UI control which is using this pointer.

  • i. Use getApplicationContext() while creating that UI control.
  • ii. Use view.getBackGround().setCallBack(null), to remove a connection between static variable and the UI control.
  • iii. Make static variable as non-static, never use statics in your class.
  • i
  • i & ii
  • i, ii, & iii
  • none

Answer: B i & ii
Description: Either use getApplicationContext() while creating UI control. Or break the link between static variable and the UI control.
Below is one example program, on memory leak and how to resolve it.
public class MemoryleakActivity extends Activity {
/** Called when the activity is first created. */
private static Drawable sBackground;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

TextView label = new TextView(this);
label.setText("Leaks are bad");

if (sBackground == null) {
sBackground = getApplicationContext().getResources().getDrawable(R.drawable.icon);
}

label.setBackgroundDrawable(sBackground);

setContentView(label);

}
@Override
protected void onDestroy() {
sBackground.setCallback(null);
super.onDestroy();
  }
}