Select chapter




Sponsored Links


  

android provab placement

1
why to extend application class, how to access common variables in all activities? What is the use of Application class?
  1. There are two contexts in Android.
    1. Activity level context
    2. Application level context
    
    Application level context will be created while creating your application. There will be only one application context shared for all the components of your application.
    So if you want to share some temporary variables with all the components of your application, then create your own class which extends Application class. Use setters and getters to share some variables in that class.
    
    Note: Make sure that you give android:name as your class which extended Application class,in the <application .. >tab of manifest file.
    
    The other uses of Application class is, if you want to do some task before loading your first activity, then write it in Application class's onCreate() method. Application class also has some useful methods which will get triggered in case of low memory, which you can use to check if your app is running on low memory to alert user.
Show Answer
Share Facebook gmail Twitter
2
what is viewholder?
  1. ViewHolder is a technique used in Adapter's getView() method,
    to reduce the no of findViewById() calls.
    Adapters are intelligent enough to reuse the old views while user scrolls throught the adapter view elements. Programmer should check if convertView is not null, then reuse it rather than creating a new view for that row.
    Apart from this we can optimize it more by reducing number of findViewById() calls by moving all those into ViewHolder class.
    Programmer can also move some reusable components like arrays or database query results also into ViewHolder to avoid unncessery function calls.
    
Show Answer
Share Facebook gmail Twitter
3
what is beanclass?
  1. A bean class is a plain old java class, which has
    1. no argument constructor
    2. all its fields as private with setters and getters
    3. and implements Serializable.
    
    Basically bean class can be used as an object which itself can hold other states and objects.
    It implements serializable enabling the programmer to transfer it out of java memory, like into some streams, or hard disk, or database, or to some network. It enable java programmer to not loose an objects state while transferring into streams.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
10
If I close the application, will it destroy all the static variables?
  1. Don't rely on static variables, because static variables may not be cleand properly on the application exit. 
    Static variables will be created when the class containing them is loaded first or used first. They will be destroyed once JVM unloads that class from the memory.
    But Android has a concept of empty process, which says your app may not be removed from the memory if it is frequently used by user, in which case your static variables will not be cleard of completely.
    Better to rely on Application class which will be created properly on application startup time and will be cleard of once user exits app. This is the best way to share some temporary variables between the components.
    
    Note: Static variables are considered as anti-design of android apps from ages.
    
    Still if you want to rely on static variables due to some reasons, then try to understand what is the scope of that variable and try to initialize some null values to it on shutting down the last component which is accessing that variable. But again it is a complicated logic.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
In MVC architecture, where is database stored?
  1. In MVC (Model-View-Controller) architecture Model will interact with Database part.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :