I was asked

Android

  • Handler
  • serializable, parcelable
  • Service, IntentService. What is inside?
  • Fragment, FragmentTransaction, commit. How does the commit method work? Is commit synchronized?
  • SynchronizationInter-process communication:  mutexes, semaphores, events, etc.
  • Collections in java
  • Memory leaks due to rotation with AsyncTask
  • RxJava
  • What is UI-thread, how does it work?
  • Loader
  • Which lifecycle methods of activity will be guaranteed invoked if OS destroys the one?

Convert byte to KB MB GB

static readonly string[] SizeSuffixes = 
                   { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
static string SizeSuffix(Int64 value)
{
    if (value < 0) { return "-" + SizeSuffix(-value); } 
    if (value == 0) { return "0.0 bytes"; }

    int mag = (int)Math.Log(value, 1024);
    decimal adjustedSize = (decimal)value / (1L << (mag * 10));

    return string.Format("{0:n1} {1}", adjustedSize, SizeSuffixes[mag]);
}