Answer: B Empty process- an app which is destroyed and still in the memory.
Description: Empty process - is an application which user is frequently visiting and closing. (Which resides in memory even after killing).
To launch frequently visited app fastly, even after destroying that app, it will be still in memory so that loading time will be reduced and user feels more comfortable. That is called as empty process.
its priority is 5 (Empty_Process). this is the last and least priority of an application or a process.
When android device goes out of memory, to reclaim some memory android will start killing all the processes starting with least priority process. Empty process is the most susceptible process to be killed in case of low memory.
Answer: C task can have n number of apps
Description: task is a collection of apps that user traverse when performing some task.
eg: while sending message, he starts with messaging application, and may move to gallery or camera to attach some photo that message. in this scenario messaging and gallery are two different apps. but for user he is doing single task only.
Answer: A Yes a task can have multiple process in it
Description: Apps and process is same. Task is a collection of one or more applications. App means process, so task can contain multiple processes.
Answer: D iv
Description: Activities, services and other components of an applications runs in single process. there can be some situations where we can allow a component of application to run in a different process. but this is possible only if user id of those two different processes are same.
Answer: D Sleep mode - means CPU will be sleeping and will not accept any command except from RIL(Radio Interface Layer) and alarms. CPU will go to sleep mode with in fraction of seconds after LCD is turned off.
Description: There is small difference in power consumption when you compare a phone with laptops.
Laptops most of the times runs on direct power through charger. (Mostly we carry charge with laptop).
Mobiles mostly run on battery power. (Rarely we carry charger with us).
By keeping this in mind, android has designed in a such a way that, phone will not consume battery power if user is not interacting with the phone. This is to increase battery back up time for user.
Thats why when LCD screen power is off (that means user is not interacting with phone), with in fraction of seconds CPU will also go to a mode (sleep mode) where it does minimal work and saves battery power. When CPU is in sleep mode, it accepts commands only from RIL (radio interface layer) which is basically sms and call functions, and alarms. Other than this CPU will stop executing other applications functions.
Note : If any application wants CPU time for its emergency work when CPU is in sleep mode, then it can request CPU time by using WAKE LOCKS.
For eg : MP3 application has to keep playing songs in its service, even though user has turned off LCD screen. That means MP3 application's service has requested CPU time by using WAKE LOCKS.
Answer: D
PARTIAL_WAKE_LOCK - use it when you need only CPU on
SCREEN_DIM_WAKE_LOCK - use it when you need CPU + Screen in dim mode
SCREEN_BRIGHT_WAKE_LOCK - use it when you need CPU + SCREEN Bright
FULL_WAKE_LOCK - use it when you need all SCREEN, CPU, Keypad in bright and on.
Description: There are 4 types of wake locks available in android power manager driver:
1. PARTIAL_WAKE_LOCK - use it when you need only CPU to be on
eg : while traveling playing mp3 audio songs, which requires only cpu to be on.
2. SCREEN_DIM_WAKE_LOCK - use it when you need CPU and Screen in dim mode
3. SCREEN_BRIGHT_WAKE_LOCK - use it when you need CPU and SCREEN in Bright mode
eg : while traveling if we want to watch a movie in the phone, then both cpu & screen should be on.
4. FULL_WAKE_LOCK - use it when you need all SCREEN, CPU, Keypad in bright and on.
eg : If user is playing a game, then cpu, screen lights, and keypads lights should be on.
Because to play a game, user might be using keyboard also to navigate or to move the elements in the game.
Answer: B Screen lights & Keyboard will be off, but CPU still running.
Description: Screen lights & Keyboard will be off, but CPU still running.
Answer: B RIL (Radio Interface Layer) & alarms
Description: Complete RIL layer( SMS, Data pockets, and Calls) & alarms will be still running even in sleep mode also.
Note : But remember all alarms will be destroyed once user switches off the phone.
Answer: B Create a pending intent to start a service, and give it to alarm to fire at every day night 12. Also make sure to acquire full wake lock in onCreate of your service and release wake lock after uploading all images.
Description: Create a pending intent to start a service, and give it to alarm to fire at every day night 12. Also make sure to acquire full wake lock in oncreate of your service and release wake lock after uploading all images. Only for broadcast receivers tied up with alarms, will hold wake locks automatically. but if you are starting a service from alarm, them alarm manager wont hold wake lock for you. it is programmers duty to hold wake locks in service.
Answer: A class MyActivity extends Activity
{
private static Drawable sBackground;
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
TextView label = new TextView(this);
label.setText("Leaks are bad");
if (sBackground == null) {
sBackground = getDrawable(R.drawable.large_bitmap);
}
label.setBackgroundDrawable(sBackground);
setContentView(label);
}
Description: First option, where static drawables are bound with process life cycle, which is pointing to label, which pointing to activity context. This is kind of dead lock situation where Android can't clean activity's resources because activity's pointer is held by label which can't be cleaned because it is pointed by process global data (static variables) drawable.
Answer: D ii & iii
Description: 1. Use fragments where ever it is possible 2. Use Dps instead of pixels 3. Use xhdpi images as well.4. avoid giving margins based on pixels, rather use margins with respect to parent 5. Use SPs for font sizes. 6. Use 9 patch images always.
Answer: D i, ii, iii, & iv
Description: All the above mentioned 4 options can be used to optimize and load items quickly.
Answer: B One process, and one Virtual machine for each application.
Description: Default android will give One process, and one Virtual machine for each application.
Answer: C option 2 is true, there may be some situations where activity will be pointed by some ui controls, which will be pointed by some static variables, which leads to memory leak in android.
Description: Java GC(Garbage Collector) doesn't guarantee about memory leaks, if it finds any memory pointed by some one, then java will assume that the memory is under use. In that case it will not clean that memory.there may be some situations where activity (this pointer) will be pointed by some UI controls, which will be pointed by some static variables, which leads to memory leak in android.
Note : Java doesn't guarantee about memory leaks. It is the programmers responsibility to use static variables and contexts properly. Else it may lead to serious memory leaks in android.
Answer: A No, it might lead to dangerous memory leaks.
Description: Having link between static variables and UI controls which points to "this" pointer (activity context), may lead to serious memory leaks. Try avoid these kind of links.
Answer: B test.java -> compile -> test.class -> dx tool -> .dex -> dvm -> final machine code
Description: .java file -- will be given to -- java compiler -- to generate -- .class file.
all .class files -- will be given to -- dx tool -- to generate single -- dex file
dex file -- will be given to -- dvm -- to generate -- final machine code.
final machine code -- will be given to -- CPU -- to execute.
Answer: D class with out a class name but with body.
Description: Anonymous classes are those for which there is no class name, but body will exist. You can create anonymous classes by extending a base class or by implementing an interface. Eg: for anonymous class is button click listeners in Android.
Answer: B Class for which we can create only one object
Description: It is a design pattern, where a class is designed in such a way that, there is only object for that class. This can be achieved in many ways, general way of implementation is by making the constructor as private, and creating and returning object through a static method of that class.
Answer: D (application)Process will be loaded into memory before loading first component of the application, and will be killed after destroying all components.But if user is visiting that application very frequently, then android might not kill the process at all to optimize the loading time of that application.
Description: If user is visiting an application very frequently, then its better to retain that application in the memory rather than killing it. Reason for this is, next time when user visits the same application no need to load that application into memory, as it is already in memory. So user will feel happy for showing application very quickly. This is called as empty process(application).
Answer: A Parcels are used in Binders. We use parcels for only IPCs, for normal serialization we use serializables.
Description: Parcel is not a general-purpose serialization mechanism.This class is designed as a high-performance IPC transport. used heavily in IBinders. for normal serialization concepts, use Serializables. since serializables are heavy and takes time, we use Parcels for IPC in embedded devices.