Mobile OS Interview Questions
Questions Answers Views Company eMail

Swift defines the AnyObject type alias to represent instances of any reference type, and it’s internally defined as a protocol. Consider the following code: var array = [AnyObject]() struct Test {} array.append(Test()) This code generates a compilation error, with the following error message: Type 'Test' does not conform to protocol 'AnyObject' The failure is obvious because a struct is a value and not a reference type, and as such it doesn’t implement and cannot be cast to the AnyObject protocol. Now consider the following code: var array = [AnyObject]() array.append(1) array.append(2.0) array.append("3") array.append([4, 5, 6]) array.append([7: "7", 8: "8"]) struct Test {} array.append(Test()) The array array is filled in with values of type respectively int, double, string, array and dictionary. All of them are value types and not reference types, and in all cases no error is reported by the compiler. Why?

1 1230

Consider the following code: let op1: Int = 1 let op2: UInt = 2 let op3: Double = 3.34 var result = op1 + op2 + op3 Where is the error and why? How can it be fixed?

1 1348

Consider the following code: var defaults = NSUserDefaults.standardUserDefaults() var userPref = defaults.stringForKey("userPref")! printString(userPref) func printString(string: String) { println(string) } Where is the bug? What does this bug cause? What’s the proper way to fix it?

1 1337

The following code snippet results in a compile time error: struct IntStack { var items = [Int]() func add(x: Int) { items.append(x) // Compile time error here. } } Explain why a compile time error occurs. How can you fix it?

1 1384

In Swift enumerations, what’s the difference between raw values and associated values?

1 2851

The String struct doesn’t provide a count or length property or method to count the number of characters it contains. Instead a global countElements() function is available. When applied to strings, what’s the complexity of the countElements function: O(1) O(n) and why?

1 1070

struct Planet { var name: String var distanceFromSun: Double } let planets = [ Planet(name: "Mercury", distanceFromSun: 0.387), Planet(name: "Venus", distanceFromSun: 0.722), Planet(name: "Earth", distanceFromSun: 1.0), Planet(name: "Mars", distanceFromSun: 1.52), Planet(name: "Jupiter", distanceFromSun: 5.20), Planet(name: "Saturn", distanceFromSun: 9.58), Planet(name: "Uranus", distanceFromSun: 19.2), Planet(name: "Neptune", distanceFromSun: 30.1) ] let result1 = { $ } let result2 = planets.reduce(0) { $0 + $1.distanceFromSun } What are the types and values of the result1 and result2 variables? Explain why.

1 1213

Consider the following code: var array1 = [1, 2, 3, 4, 5] var array2 = array1 array2.append(6) var len = array1.count What’s the value of the len variable, and why?

1 1193

what is the procedure of using D2MS server in cloud messaging in android

Tech Mentro,


what is preferences

Tech Mentro, Google,


sap bw online classes

SAP Labs,

1 416

Un-Answered Questions { Mobile OS }

Explain AndroidManifest.xmlfile in detail.


If the Activity is showing an animation that indicates some kind of progress, what issue might you encounter and how could you address it?


Explain which all events will perform an ios application in background


Describe android Activities in brief.


Explain what is the stack of autorelease pools. How autorelease pool work under the hood?


What is a ContentProvider and what is it typically used for?


what is your preferred programming language? Why? How long will it take you to learn a new programming language?


Under what condition could the code sample below crash your application? How would you modify the code to avoid this potential problem? Explain your answer.     Intent sendIntent = new Intent();     sendIntent.setAction(Intent.ACTION_SEND);     sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);     sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type     startActivity(sendIntent);


Mention what is the difference between Swift and ‘Objective-C’ language?


In mapKit frame work, how to get current user location


what is preferences


When dealing with property declarations, what is the difference between atomic and non-atomic?


Explain your process for tracing and fixing a memory leak


How will you implement sets and the intersection operation? Complexity?


How to get the geolocation data on a picture?