iOS Interview Questions & Answers-1

1) Explain what is Xcode?

Xcode is Apple’s integrated development environment (IDE) that you use to design apps for Apple products.  It provides various tools to manage your entire development workflow from creating your app, to testing, submitting and optimizing it to the App store.

2) Explain what is struct?

A struct is a special C data type that encapsulates other pieces of data into a single cohesive unit.

3) Explain how you can add frameworks in Xcode project?

To add frameworks in Xcode project

    Choose the project file from the project navigator on the left side of the project window
    Choose the target where you want to add frameworks in the project settings editor
    Choose the “Build Phases” tab, and select the small triangle next to “Link Binary With Libraries” to view all of the frameworks in your application
    To add frameworks click on “+” sign below the list of frameworks
    To choose multiple frameworks, press and hold the command key while choosing the framework

4) Mention what is the difference between bounds and frame?

    Frame: The frame of a view is the rectangle, represented as a location (X, Y) and size (width, height) corresponding to the superview it is contained within
    Bounds: The bounds of a view is the rectangle, represented as a location (X, Y) and size (width, height) corresponding to its own co-ordinate system (0,0)

5) Explain what is the difference between Xcode, Cocoa and Objective C?

    Xcode: It is the integrated development environment (IDE) that developer use to write software for IOS or OS X.
    Objective-C: It is the language most preferred by developer to write programs for apple
    Cocoa: It is the application

Logo_xcode

6) Explain what is Xcode command line tools package?

Command line tools package is a self-contained package available separately from Xcode. It enables you to do command line development in OS X.  It consists of two components like command line tools such as Clang and OS X SDK.

7) Mention what are the new features in Xcode 6?

In Xcode 6,  new features include

    Support for Swift: Xcode 6 explicitly supports the Swift code, it is very simple and easy to make a brand new app using 100% swift code to existing frameworks.
    Playgrounds: It enables the interactive experience of a scripting language, like you can show variables in a graph, watch an animated SpriteKit Scene or inspect each step when drawing a view. Once you are done with code in the playground, you can move it into your project
    Command Line: You can use Swift syntax to interact and evaluate with your running app or write new code in a script like environment
    Performance Testing: The XCTest framework is extended to support performance test, and is completely synchronized with Xcode and Xcode Server. It also raises alerts for regression when test results change
    View Debugging: Xcode allows easy debugging and includes new debugging tools like debug gauges to monitor I/O usage and enhance iCloud gauge

8) Mention what is the use of PO command in Xcode?

PO command is useful during debug time. In normal scenario, to print the value of a variable, you have to move the mouse pointer there and select print description print value of it.  With PO command, you can print value by just writing the “PO variable name” in output window, and press enter.

9) Mention what are the two different smart groups in Xcode?

Simple smart groups are classified into two categories

    Simple filter smart group: It matches files based on file name “globbing” used in the shell
    Simple expression smart group: It matches files using regular expression

10) Explain how you can delete a smart group created in Xcode?

It is not possible to delete smart groups individually, so you can delete smart group in Xcode either by

    Deleting all the smart groups saved in an individual project
    Or by deleting all the global smart groups available in the project

11) Explain how you can migrate to Xcode?

To migrate to Xcode you need to import your ProjectBuilderWO projects into Xcode by following steps

    Select file -> Import project -> Open the import project assistant
    From the import project assistant, select the import projectBuilderWO projects and tap on the next button
    Choose the button to select the project document
    Enter the name you want to use for the new Xcode project in the New Project Name Field and click finish

12) Mention what are the source items used by Xcode?

Xcode uses four different types of source items

    Source File
    Source Group
    Source Folder
    Framework

13) What is the short cut to open the “Code Snippet Library” in Xcode?

(CMD+OPT+Cntrl+2) is the short-cut to open the “Code Snippet Library” in Xcode.

14) Mention the short-cut to edit variables in Scope?

To edit variables in Scope, you can use the command Cntrl+cmd+E.

15) Mention what are the build phases available in Xcode?

There are three build phases in Xcode that is available by default

    Compile Sources
    Link binary with libraries
    Copy bundle resources

16) Explain how app delegate is declared by Xcode project templates?

App delegate is defined as a sub-class of UIResponder by Xcode project templates.

17) Mention what are all instruments available in Xcode?

To trace and profile Mac OS X and iOS code an application is used referred as Instruments. It allows you to track one or more than one processes and analyze the collected data.  It helps you to understand the behavior of both operating system and the user programs.

18) Explain what does @synthesize do?

Keyword @synthesize tell the compiler that it should create the setter or getter for the property if you do not supply them with the @implementation block.

19) Explain what is Swift Programming Language?

Swift is a programming language and system for creating applications for iOS and OS X. It is an innovative programming language for Cocoa and Cocoa Touch.

20) Explain how you define variables in Swift language?

Variables and constants must be declared before they are used. You announce constants with the let keyword and variables with the var keyword. Both variables and dictionaries are described using brackets. For example,

Var  Guru99 = “This is Guru99”

Let ksomeconstant = 30

21) Explain how Swift program is deployed?

Swift program deploys the application in a Tomcat installation by default. The deploy script bundles the client code into JavaScript, gathers all the server side classes required and packages them into file Hello.war. This file together with a GWT jar and a Swift runtime jar is copied into the Tomcat installation. If CATALINA_HOME is not set, these files require to be copied manually.

22) Mention what are the features of Swift Programming?

    It eliminates entire classes of unsafe code
    Variables are always initialized before use
    Arrays and integers are checked for overflow
    Memory is managed automatically
    Instead of using “if” statement in conditional programming, swift has “switch” function

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

Difference between ‘C’ and ‘Swift’ language is that
Swift    Objective-C

    In a swift, the variable and constants are declared before their use
    You have to use “let” keyword for constant and “var” keyword for variable
    There is no need to end code with semi-colon
    Concatenating strings is easy in swift and allows to make a new string from a mix of constants,  literals, variables, as well as expressions
    Swift does not require to create a separate interface like Objective C. You can define classes in a single file (.swift)
    Swift enables you to define methods in class, structure or enumeration
    In Swift, you use “ +=” Operator to add an item

   

    In objective C, you have to declare variable as NSString and constant as int
    In objective C, variable is declared as “ and constant as “
    The code ends with semi-colon
    In objective C, you have to choose between NSMutableString and NSString for string to be modified.
    For classes, you create separate interface (.h) and implementation (.m) files for classes
    Objective does not allow this
    In C, you use “addObject”: method of NSMutable array to append a new item to an array

iOS-Swift-Logo

24) Mention what are the type of integers does Swift have?

Swift provides unsigned and signed integers in 8, 16, 32 and 64 bit forms. Similar to C these integers follow a naming convention. For instance, unsigned integer is denoted by type UInt8 while 32 bit signed integer will be denoted by type Int32.

25) Mention what is the Floating point numbers and what are the types of floating number in Swift?

Floating numbers are numbers with a fractional component, like 3.25169 and -238.21.  Floating point types can represent a wider range of values than integer types. There are two signed floating point number

    Double: It represents a 64 bit floating point number, it is used when floating point values must be very large
    Float: It represents a 32 bit floating point number, it is used when floating point values does not need 64 bit precision

26) Explain how multiple line comment can be written in swift?

Multiple line comment can be written as forward-slash followed by an asterisk (/*)  and end with an asterisk followed by a forward slash (*/).

27) What is de-initializer and how it is written in Swift?

A de-initializer is declared immediately before a class instance is de-allocated.  You write de-initializer with the deinit keyword.  De-initializer is written without any parenthesis, and it does not take any parameters. It is written as

deinit  {

// perform the deinitialization

}

28) Mention what are the collection types available in Swift?

In Swift, collection types come in two varieties Array and Dictionary

    Array: You can create an Array of a single type or an array with multiple types. Swift usually prefers the former one

Example for single type array is,

Var cardName : [String] = [ “Robert” , “Lisa” , “Kevin”]

// Swift can infer [String] so we can also write it as:

Var cardNames = [ “Robert”, “Lisa”, “Kevin”] // inferred as [String]

To add an array you need to use the subscript println(CardNames[0])

    Dictionary: It is similar to a Hash table as in other programming language. A dictionary enables you to store key-value pairs and access the value by providing the key

var cards = [ “Robert”: 22, “Lisa” : 24, and “Kevin”: 26]

29) List out what are the control transfer statements used in Swift?

Control transfer statements used in Swift includes

    Continue
    Break
    Fallthrough
    Return

30) Explain what is optional chaining?

Optional chaining is a process of querying and calling properties. Multiple queries can be chained together, and if any link in the chain is nil then, the entire chain fails.

31) How base-class is defined in Swift?

In Swift the classes are not inherited from the base class and the classes that you define without specifying its superclass, automatically becomes the base-class.

32) Explain what Lazy stored properties is and when it is useful?

Lazy stored properties are used for a property whose initial values is not calculated until the first time it is used.  You can declare a lazy stored property by writing the lazy modifier before its declaration. Lazy properties are useful when the initial value for a property is reliant on outside factors whose values are unknown.

33) Mention what is the characteristics of Switch in Swift?

    It supports any kind of data, and not only synchronize but also checks for equality
    When a case is matched in switch, the program exists from the switch case and does not continue checking next cases. So you don’t need to explicitly break out the switch at the end of case
    Switch statement must be exhaustive, which means that you have to cover all possible values for your variable
    There is no fallthrough in switch statements and therefore break is not required

2 comments:

  1. This is a very nice article. thank you for publishing this. i can understand this easily.!!..iOS Swift Online Course India

    ReplyDelete

  2. Are you in search of a relevant collection of IOS interview Questions to brush up IOS concepts? Read a thoroughly community-driven set of interview questions posted by a coding tag that would help the novices to face tricky questions asked by recruiters. Through this series, you can easily discover solutions to technical concepts related to IOS.

    ReplyDelete